Socket
Socket
Sign inDemoInstall

release-it

Package Overview
Dependencies
Maintainers
1
Versions
400
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

release-it - npm Package Compare versions

Comparing version 15.0.0-esm.2 to 15.0.0-esm.3

3

config/release-it.json

@@ -43,3 +43,4 @@ {

"proxy": null,
"skipChecks": false
"skipChecks": false,
"web": false
},

@@ -46,0 +47,0 @@ "gitlab": {

@@ -68,3 +68,3 @@ import _ from 'lodash';

const name = await reduceUntil(plugins, plugin => plugin.getName());
const latestVersion = await reduceUntil(plugins, plugin => plugin.getLatestVersion());
const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion));

@@ -71,0 +71,0 @@

import { EOL } from 'os';
import _ from 'lodash';
import findUp from 'find-up';
import { execa } from 'execa';
import { format, e } from '../../util.js';

@@ -15,2 +15,8 @@ import GitBase from '../GitBase.js';

const isGitRepo = () =>
execa('git', ['rev-parse', '--git-dir']).then(
() => true,
() => false
);
class Git extends GitBase {

@@ -23,3 +29,3 @@ constructor(...args) {

static async isEnabled(options) {
return options !== false && (await findUp('.git', { type: 'directory' }));
return options !== false && (await isGitRepo());
}

@@ -26,0 +32,0 @@

@@ -102,3 +102,3 @@ import { EOL } from 'os';

});
return this.exec(`git describe --tags --abbrev=0 ${sha}^`, { options }).catch(() => null);
return this.exec(`git describe --tags --abbrev=0 "${sha}^"`, { options }).catch(() => null);
}

@@ -105,0 +105,0 @@ }

import fs from 'fs';
import path from 'path';
import open from 'open';
import { Octokit } from '@octokit/rest';
import globby from 'globby';
import { globby } from 'globby';
import mime from 'mime-types';
import _ from 'lodash';
import retry from 'async-retry';
import newGithubReleaseUrl from 'new-github-release-url';
import { format, parseVersion, readJSON, e } from '../../util.js';

@@ -24,3 +26,3 @@ import Release from '../GitRelease.js';

const { status, message } = err;
const { headers } = err.response;
const headers = err.response ? err.response.headers : {};
msg = `${_.get(headers, 'status', status)} (${message})`;

@@ -40,9 +42,14 @@ }

const { skipChecks, tokenRef, update } = this.options;
const { skipChecks, tokenRef, web, update } = this.options;
if (!skipChecks) {
if (!this.token) {
throw e(`Environment variable "${tokenRef}" is required for GitHub releases.`, docs);
if (!this.token || web) {
if (!web) {
this.log.warn(`Environment variable "${tokenRef}" is required for automated GitHub Releases.`);
this.log.warn('Falling back to web-based GitHub Release.');
}
this.setContext({ isWeb: true });
return;
}
if (!skipChecks) {
// If we're running on GitHub Actions, we can skip the authentication and

@@ -113,3 +120,3 @@ // collaborator checks. Ref: https://bit.ly/2vsyRzu

const { assets } = this.options;
const { isUpdate } = this.getContext();
const { isWeb, isUpdate } = this.getContext();
const { isCI } = this.config;

@@ -120,3 +127,6 @@

if (isCI) {
if (isWeb) {
const task = () => this.createWebRelease();
return this.step({ task, label: 'Generating link to GitHub Release web interface', prompt: 'release' });
} else if (isCI) {
await this.step({ task: () => this[publishMethod](), label: `GitHub ${type} release` });

@@ -292,2 +302,30 @@ return this.step({ enabled: assets, task: () => this.uploadAssets(), label: 'GitHub upload assets' });

generateWebUrl() {
const host = this.options.host || this.getContext('repo.host');
const isGitHub = host === 'github.com';
const options = this.getOctokitReleaseOptions();
const url = newGithubReleaseUrl({
user: options.owner,
repo: options.repo,
tag: options.tag_name,
isPrerelease: options.prerelease,
title: options.name,
body: options.body
});
return isGitHub ? url : url.replace('github.com', host);
}
async createWebRelease() {
const { isCI } = this.config;
const { tagName } = this.config.getContext();
const url = this.generateWebUrl();
if (isCI) {
this.setContext({ isReleased: true, releaseUrl: url });
} else {
await open(url);
this.setContext({ isReleased: true, releaseUrl: this.getReleaseUrlFallback(tagName) });
}
}
updateRelease() {

@@ -294,0 +332,0 @@ const { isDryRun } = this.config;

import fs from 'fs';
import path from 'path';
import got from 'got';
import globby from 'globby';
import { globby } from 'globby';
import FormData from 'form-data';

@@ -6,0 +6,0 @@ import _ from 'lodash';

@@ -56,6 +56,2 @@ import semver from 'semver';

getLatestVersion() {
return '0.0.0';
}
getIncrement(options) {

@@ -62,0 +58,0 @@ return options.increment;

import sh from 'shelljs';
import execa from 'execa';
import { execa } from 'execa';
import _debug from 'debug';

@@ -4,0 +4,0 @@ import { format } from './util.js';

@@ -1,2 +0,2 @@

import ora from 'ora';
import { oraPromise } from 'ora';
import { format } from './util.js';

@@ -9,3 +9,3 @@

this.config = container.config;
this.ora = container.ora || ora;
this.ora = container.ora || oraPromise;
}

@@ -23,3 +23,3 @@ show({ enabled = true, task, label, external = false, context }) {

const text = format(label, context);
this.ora.promise(awaitTask, text);
this.ora(awaitTask, text);
}

@@ -26,0 +26,0 @@

{
"name": "release-it",
"version": "15.0.0-esm.2",
"version": "15.0.0-esm.3",
"description": "Generic CLI tool to automate versioning and package publishing related tasks.",

@@ -65,20 +65,21 @@ "keywords": [

"@iarna/toml": "2.2.5",
"@octokit/rest": "18.6.7",
"async-retry": "1.3.1",
"chalk": "4.1.1",
"cosmiconfig": "7.0.0",
"debug": "4.3.2",
"@octokit/rest": "18.12.0",
"async-retry": "1.3.3",
"chalk": "4.1.2",
"cosmiconfig": "7.0.1",
"debug": "4.3.3",
"deprecated-obj": "2.0.0",
"execa": "5.1.1",
"find-up": "5.0.0",
"execa": "6.0.0",
"form-data": "4.0.0",
"git-url-parse": "11.5.0",
"globby": "11.0.4",
"got": "11.8.2",
"inquirer": "8.1.1",
"is-ci": "3.0.0",
"git-url-parse": "11.6.0",
"globby": "12.0.2",
"got": "11.8.3",
"inquirer": "8.2.0",
"is-ci": "3.0.1",
"lodash": "4.17.21",
"mime-types": "2.1.31",
"ora": "5.4.1",
"os-name": "4.0.0",
"mime-types": "2.1.34",
"new-github-release-url": "2.0.0",
"open": "8.4.0",
"ora": "6.0.1",
"os-name": "5.0.1",
"parse-json": "5.2.0",

@@ -91,3 +92,3 @@ "semver": "7.3.5",

"yaml": "1.10.2",
"yargs-parser": "20.2.9"
"yargs-parser": "21.0.0"
},

@@ -97,16 +98,16 @@ "devDependencies": {

"ava": "3.15.0",
"codecov": "3.8.2",
"eslint": "7.30.0",
"codecov": "3.8.3",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-ava": "12.0.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-ava": "13.1.0",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-prettier": "4.0.0",
"markdown-toc": "1.2.0",
"mock-fs": "5.0.0",
"mock-fs": "5.1.2",
"mock-stdio": "1.0.3",
"nock": "13.1.1",
"nock": "13.2.1",
"nyc": "15.1.0",
"prettier": "2.3.2",
"sinon": "11.1.1",
"strip-ansi": "6.0.0"
"prettier": "2.5.0",
"sinon": "12.0.1",
"strip-ansi": "7.0.1"
},

@@ -113,0 +114,0 @@ "engines": {

@@ -159,9 +159,7 @@ # Release It! 🚀

The "Releases" tab on GitHub projects links to a page to store the changelog cq. release notes. To add
GitHub projects can have releases attached to Git tags, containing release notes and assets. There are two ways to add
[GitHub releases](https://help.github.com/articles/creating-releases) in your release-it flow:
- Configure `github.release: true`
- Obtain a [personal access token](https://github.com/settings/tokens/new?scopes=repo&description=release-it)
(release-it only needs "repo" access; no "admin" or other scopes).
- Make sure the token is [available as an environment variable](./docs/environment-variables.md).
1. Automated (requires a `GITHUB_TOKEN`)
2. Manual (using the GitHub web interface with pre-populated fields)

@@ -172,3 +170,4 @@ → See [GitHub Releases](./docs/github-releases.md) for more details.

[GitLab releases](https://docs.gitlab.com/ce/user/project/releases/) work just like GitHub releases:
GitLab projects can have releases attached to Git tags, containing release notes and assets. To automate
[GitLab releases](https://docs.gitlab.com/ce/user/project/releases/):

@@ -327,3 +326,3 @@ - Configure `gitlab.release: true`

- [ember-cli/ember-cli](https://github.com/ember-cli/ember-cli)
[react-native-paper](https://github.com/callstack/react-native-paper)
- [react-native-paper](https://github.com/callstack/react-native-paper)
- [js-cookie/js-cookie](https://github.com/js-cookie/js-cookie)

@@ -330,0 +329,0 @@ - [mirumee/saleor](https://github.com/mirumee/saleor)

import test from 'ava';
import mock from 'mock-fs';
import isCI from 'is-ci';
import Config from '../lib/config.js';

@@ -47,4 +48,3 @@ import { readJSON } from '../lib/util.js';

test('should detect CI mode', async t => {
const { default: isCI } = await import('is-ci');
test('should detect CI mode', t => {
const config = new Config();

@@ -51,0 +51,0 @@ t.is(config.options.ci, isCI);

@@ -21,11 +21,7 @@ import test from 'ava';

test.serial('should validate token', async t => {
test.serial('should check token and perform checks', async t => {
const tokenRef = 'MY_GITHUB_TOKEN';
const options = { github: { release: true, tokenRef, pushRepo } };
const github = factory(GitHub, { options });
delete process.env[tokenRef];
await t.throwsAsync(github.init(), {
message: /^Environment variable "MY_GITHUB_TOKEN" is required for GitHub releases/
});
process.env[tokenRef] = '123'; // eslint-disable-line require-atomic-updates

@@ -38,2 +34,14 @@

test.serial('should check token and warn', async t => {
const tokenRef = 'MY_GITHUB_TOKEN';
const options = { github: { release: true, tokenRef, pushRepo } };
const github = factory(GitHub, { options });
delete process.env[tokenRef];
await t.notThrowsAsync(github.init());
t.is(github.log.warn.args[0][0], 'Environment variable "MY_GITHUB_TOKEN" is required for automated GitHub Releases.');
t.is(github.log.warn.args[1][0], 'Falling back to web-based GitHub Release.');
});
test('should release and upload assets', async t => {

@@ -53,2 +61,3 @@ const options = {

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');

@@ -83,2 +92,3 @@

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');

@@ -115,5 +125,6 @@

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('71f1812');
exec.withArgs('git describe --tags --match=* --abbrev=0 71f1812').resolves('2.0.1');
exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('a123456');
exec.withArgs('git describe --tags --abbrev=0 "a123456^"').resolves('2.0.1');

@@ -149,5 +160,6 @@ interceptAuthentication();

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('71f1812');
exec.withArgs('git describe --tags --match=* --abbrev=0 71f1812').resolves('2.0.1');
exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('b123456');
exec.withArgs('git describe --tags --abbrev=0 "b123456^"').resolves('2.0.1');

@@ -203,2 +215,3 @@ interceptAuthentication();

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('1.0.0');

@@ -220,2 +233,3 @@

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('1.0.0');

@@ -319,2 +333,3 @@ exec.withArgs('git remote get-url upstream').resolves('https://my-custom-host.org/user/repo');

const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('v1.0.0');

@@ -339,1 +354,54 @@

});
test('should generate GitHub web release url', async t => {
const options = {
github: {
pushRepo,
release: true,
web: true,
releaseName: 'Release ${tagName}',
releaseNotes: 'echo Custom notes'
}
};
const github = factory(GitHub, { options });
const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
await runTasks(github);
const { isReleased, releaseUrl } = github.getContext();
t.true(isReleased);
t.is(
releaseUrl,
'https://github.com/user/repo/releases/new?tag=2.0.2&title=Release+2.0.2&body=Custom+notes&prerelease=false'
);
exec.restore();
});
test('should generate GitHub web release url for enterprise host', async t => {
const options = {
github: {
pushRepo: 'git://my-custom-host.org:user/repo',
release: true,
web: true,
host: 'my-custom-host.org',
releaseName: 'The Launch',
releaseNotes: 'echo It happened'
}
};
const github = factory(GitHub, { options });
const exec = sinon.stub(github.shell, 'exec').callThrough();
exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
await runTasks(github);
const { isReleased, releaseUrl } = github.getContext();
t.true(isReleased);
t.is(
releaseUrl,
'https://my-custom-host.org/user/repo/releases/new?tag=2.0.2&title=The+Launch&body=It+happened&prerelease=false'
);
exec.restore();
});

@@ -134,3 +134,3 @@ import test from 'ava';

name: undefined,
latestVersion: undefined,
latestVersion: '0.0.0',
version: undefined

@@ -137,0 +137,0 @@ });

@@ -7,5 +7,3 @@ import test from 'ava';

test.beforeEach(t => {
t.context.ora = {
promise: sinon.spy()
};
t.context.ora = sinon.spy();
});

@@ -28,3 +26,3 @@

t.is(task.callCount, 0);
t.is(ora.promise.callCount, 0);
t.is(ora.callCount, 0);
});

@@ -40,5 +38,5 @@

t.is(task.callCount, 1);
t.is(ora.promise.callCount, 1);
t.is(ora.promise.firstCall.args[0], task.firstCall.returnValue);
t.is(ora.promise.firstCall.args[1], label);
t.is(ora.callCount, 1);
t.is(ora.firstCall.args[0], task.firstCall.returnValue);
t.is(ora.firstCall.args[1], label);
});

@@ -53,3 +51,3 @@

t.is(task.callCount, 1);
t.is(ora.promise.callCount, 0);
t.is(ora.callCount, 0);
});

@@ -64,3 +62,3 @@

t.is(task.callCount, 1);
t.is(ora.promise.callCount, 1);
t.is(ora.callCount, 1);
});

@@ -400,2 +400,43 @@ import path from 'path';

test.serial('should use custom changelog command with context', async t => {
const { bare } = t.context;
const project = path.basename(bare);
const owner = path.basename(path.dirname(bare));
sh.exec('git tag v1.0.0');
gitAdd('line', 'file', 'More file');
interceptGitHubAuthentication();
interceptGitHubCollaborator({ owner, project });
interceptGitHubCreate({
owner,
project,
body: {
tag_name: 'v1.1.0',
name: 'Release 1.1.0',
body: 'custom-changelog-generator --from=v1.0.0 --to=v1.1.0',
draft: false,
prerelease: false
}
});
const container = getContainer({
increment: 'minor',
github: {
release: true,
releaseNotes: 'echo custom-changelog-generator --from=${latestTag} --to=${tagName}',
pushRepo: `https://github.com/${owner}/${project}`
}
});
const exec = sinon.spy(container.shell, 'execStringCommand');
await runTasks({}, container);
const command = exec.args.find(([command]) => command.includes('custom-changelog-generator'));
t.is(command[0], 'echo custom-changelog-generator --from=v1.0.0 --to=v1.1.0');
exec.restore();
});
{

@@ -402,0 +443,0 @@ test.serial('should run all hooks', async t => {

@@ -59,3 +59,3 @@ import _ from 'lodash';

const latestVersion = (await plugin.getLatestVersion()) || '1.0.0';
const changelog = (await plugin.getChangelog(latestVersion)) || null;
const changelog = (await plugin.getChangelog()) || null;
const increment = getIncrement(plugin, { latestVersion });

@@ -62,0 +62,0 @@

@@ -152,3 +152,3 @@ import test from 'ava';

t.deepEqual(getIncrement.firstCall.args[0], {
latestVersion: '0.0.0',
latestVersion: '1.0.0',
increment: 'minor',

@@ -159,12 +159,12 @@ isPreRelease: false,

t.is(getIncrementedVersionCI.callCount, 1);
t.deepEqual(getIncrementedVersionCI.firstCall.args[0], { latestVersion: '0.0.0', increment: 'minor' });
t.is(await incrementVersion.firstCall.returnValue, '0.1.0');
t.deepEqual(getIncrementedVersionCI.firstCall.args[0], { latestVersion: '1.0.0', increment: 'minor' });
t.is(await incrementVersion.firstCall.returnValue, '1.1.0');
t.is(incrementVersion.callCount, 1);
t.deepEqual(incrementVersion.firstCall.args[0], { latestVersion: '0.0.0', increment: 'minor' });
t.is(incrementVersion.firstCall.returnValue, '0.1.0');
t.deepEqual(incrementVersion.firstCall.args[0], { latestVersion: '1.0.0', increment: 'minor' });
t.is(incrementVersion.firstCall.returnValue, '1.1.0');
const { latestVersion, version, isPreRelease, preReleaseId } = v.config.getContext();
t.is(latestVersion, '0.0.0');
t.is(version, '0.1.0');
t.is(latestVersion, '1.0.0');
t.is(version, '1.1.0');
t.is(isPreRelease, false);
t.is(preReleaseId, null);
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc