Socket
Socket
Sign inDemoInstall

@changesets/cli

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@changesets/cli - npm Package Compare versions

Comparing version 2.16.0 to 2.17.0

22

CHANGELOG.md
# @changesets/cli
## 2.17.0
### Minor Changes
- [#626](https://github.com/atlassian/changesets/pull/626) [`bc611cf`](https://github.com/atlassian/changesets/commit/bc611cf2104ff8170e9ea8acb10952ea8cc2a784) Thanks [@Andarist](https://github.com/Andarist)! - From now on, changeset files starting with a dot (e.g. `.ignored-temporarily.md`) will be be ignored and kept around after versioning. This allows you to prepare a changeset for something that isn't supposed to be released immediately. An example use case could involve code hidden behind a feature flag.
### Patch Changes
- [#582](https://github.com/atlassian/changesets/pull/582) [`e89e28a`](https://github.com/atlassian/changesets/commit/e89e28a05f5fa43307db73812a6bcd269b62ddee) Thanks [@Andarist](https://github.com/Andarist)! - Add support for publishConfig.registry
- Updated dependencies [[`bc611cf`](https://github.com/atlassian/changesets/commit/bc611cf2104ff8170e9ea8acb10952ea8cc2a784), [`e89e28a`](https://github.com/atlassian/changesets/commit/e89e28a05f5fa43307db73812a6bcd269b62ddee)]:
- @changesets/read@0.5.0
- @changesets/types@4.0.1
- @changesets/get-release-plan@3.0.1
- @changesets/apply-release-plan@5.0.1
- @changesets/assemble-release-plan@5.0.1
- @changesets/config@1.6.1
- @changesets/get-dependents-graph@1.2.2
- @changesets/git@1.1.2
- @changesets/pre@1.0.7
- @changesets/write@0.1.5
## 2.16.0

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

89

dist/cli.cjs.dev.js

@@ -594,5 +594,7 @@ 'use strict';

function getCorrectRegistry() {
let registry = process.env.npm_config_registry === "https://registry.yarnpkg.com" ? undefined : process.env.npm_config_registry;
return registry;
function getCorrectRegistry(packageJson) {
var _packageJson$publishC, _packageJson$publishC2;
const registry = (_packageJson$publishC = packageJson === null || packageJson === void 0 ? void 0 : (_packageJson$publishC2 = packageJson.publishConfig) === null || _packageJson$publishC2 === void 0 ? void 0 : _packageJson$publishC2.registry) !== null && _packageJson$publishC !== void 0 ? _packageJson$publishC : process.env.npm_config_registry;
return !registry || registry === "https://registry.yarnpkg.com" ? "https://registry.npmjs.org" : registry;
}

@@ -641,5 +643,5 @@

}
function getPackageInfo(pkgName) {
function getPackageInfo(packageJson) {
return npmRequestLimit(async () => {
logger.info(`npm info ${pkgName}`); // Due to a couple of issues with yarnpkg, we also want to override the npm registry when doing
logger.info(`npm info ${packageJson.name}`); // Due to a couple of issues with yarnpkg, we also want to override the npm registry when doing
// npm info.

@@ -651,8 +653,3 @@ // Issues: We sometimes get back cached responses, i.e old data about packages which causes

const envOverride = {
npm_config_registry: getCorrectRegistry()
};
let result = await spawn__default['default']("npm", ["info", pkgName, "--json"], {
env: Object.assign({}, process.env, envOverride)
}); // Github package registry returns empty string when calling npm info
let result = await spawn__default['default']("npm", ["info", packageJson.name, "--registry", getCorrectRegistry(packageJson), "--json"]); // Github package registry returns empty string when calling npm info
// for a non-existant package instead of a E404

@@ -671,7 +668,9 @@

}
async function infoAllow404(pkgName) {
let pkgInfo = await getPackageInfo(pkgName);
async function infoAllow404(packageJson) {
var _pkgInfo$error;
if (pkgInfo.error && pkgInfo.error.code === "E404") {
logger.warn(`Received 404 for npm info ${chalk__default['default'].cyan(`"${pkgName}"`)}`);
let pkgInfo = await getPackageInfo(packageJson);
if (((_pkgInfo$error = pkgInfo.error) === null || _pkgInfo$error === void 0 ? void 0 : _pkgInfo$error.code) === "E404") {
logger.warn(`Received 404 for npm info ${chalk__default['default'].cyan(`"${packageJson.name}"`)}`);
return {

@@ -684,3 +683,3 @@ published: false,

if (pkgInfo.error) {
logger.error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk__default['default'].cyan(`"${pkgName}"`)}`);
logger.error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk__default['default'].cyan(`"${packageJson.name}"`)}`);
logger.error(pkgInfo.error.summary);

@@ -785,2 +784,33 @@ if (pkgInfo.error.detail) logger.error(pkgInfo.error.detail);

const isCustomRegistry = registry => !!registry && registry !== "https://registry.npmjs.org" && registry !== "https://registry.yarnpkg.com";
const getTwoFactorState = ({
otp,
publicPackages
}) => {
if (otp) {
return {
token: otp,
isRequired: Promise.resolve(true)
};
}
if (isCI || publicPackages.some(pkg => {
var _pkg$packageJson$publ;
return isCustomRegistry((_pkg$packageJson$publ = pkg.packageJson.publishConfig) === null || _pkg$packageJson$publ === void 0 ? void 0 : _pkg$packageJson$publ.registry);
}) || isCustomRegistry(process.env.npm_config_registry)) {
return {
token: null,
isRequired: Promise.resolve(false)
};
}
return {
token: null,
// note: we're not awaiting this here, we want this request to happen in parallel with getUnpublishedPackages
isRequired: getTokenIsRequired()
};
};
async function publishPackages({

@@ -795,10 +825,6 @@ packages,

const publicPackages = packages.filter(pkg => !pkg.packageJson.private);
let twoFactorState = otp === undefined ? {
token: null,
isRequired: isCI || publicPackages.some(x => x.packageJson.publishConfig && x.packageJson.publishConfig.registry && x.packageJson.publishConfig.registry !== "https://registry.npmjs.org" && x.packageJson.publishConfig.registry !== "https://registry.yarnpkg.com") || process.env.npm_config_registry !== undefined && process.env.npm_config_registry !== "https://registry.npmjs.org" && process.env.npm_config_registry !== "https://registry.yarnpkg.com" ? Promise.resolve(false) : // note: we're not awaiting this here, we want this request to happen in parallel with getUnpublishedPackages
getTokenIsRequired()
} : {
token: otp,
isRequired: Promise.resolve(true)
};
const twoFactorState = getTwoFactorState({
otp,
publicPackages
});
const unpublishedPackagesInfo = await getUnpublishedPackages(publicPackages, preState);

@@ -822,5 +848,5 @@

} = pkg.packageJson;
const localAccess = publishConfig && publishConfig.access;
const localAccess = publishConfig === null || publishConfig === void 0 ? void 0 : publishConfig.access;
logger.info(`Publishing ${chalk__default['default'].cyan(`"${name}"`)} at ${chalk__default['default'].green(`"${version}"`)}`);
const publishDir = publishConfig && publishConfig.directory ? path.join(pkg.dir, publishConfig.directory) : pkg.dir;
const publishDir = (publishConfig === null || publishConfig === void 0 ? void 0 : publishConfig.directory) ? path.join(pkg.dir, publishConfig.directory) : pkg.dir;
const publishConfirmation = await publish(name, {

@@ -839,5 +865,6 @@ cwd: publishDir,

async function getUnpublishedPackages(packages, preState) {
const results = await Promise.all(packages.map(async pkg => {
const config = pkg.packageJson;
const response = await infoAllow404(config.name);
const results = await Promise.all(packages.map(async ({
packageJson
}) => {
const response = await infoAllow404(packageJson);
let publishedState = "never";

@@ -856,4 +883,4 @@

return {
name: config.name,
localVersion: config.version,
name: packageJson.name,
localVersion: packageJson.version,
publishedState: publishedState,

@@ -860,0 +887,0 @@ publishedVersions: response.pkgInfo.versions || []

@@ -346,4 +346,6 @@ "use strict";

function getCorrectRegistry() {
return "https://registry.yarnpkg.com" === process.env.npm_config_registry ? void 0 : process.env.npm_config_registry;
function getCorrectRegistry(packageJson) {
var _packageJson$publishC, _packageJson$publishC2;
const registry = null !== (_packageJson$publishC = null == packageJson || null === (_packageJson$publishC2 = packageJson.publishConfig) || void 0 === _packageJson$publishC2 ? void 0 : _packageJson$publishC2.registry) && void 0 !== _packageJson$publishC ? _packageJson$publishC : process.env.npm_config_registry;
return registry && "https://registry.yarnpkg.com" !== registry ? registry : "https://registry.npmjs.org";
}

@@ -382,11 +384,6 @@

function getPackageInfo(pkgName) {
function getPackageInfo(packageJson) {
return npmRequestLimit((async () => {
logger.info("npm info " + pkgName);
const envOverride = {
npm_config_registry: getCorrectRegistry()
};
let result = await spawn__default.default("npm", [ "info", pkgName, "--json" ], {
env: Object.assign({}, process.env, envOverride)
});
logger.info("npm info " + packageJson.name);
let result = await spawn__default.default("npm", [ "info", packageJson.name, "--registry", getCorrectRegistry(packageJson), "--json" ]);
return "" === result.stdout.toString() ? {

@@ -400,5 +397,6 @@ error: {

async function infoAllow404(pkgName) {
let pkgInfo = await getPackageInfo(pkgName);
if (pkgInfo.error && "E404" === pkgInfo.error.code) return logger.warn("Received 404 for npm info " + chalk__default.default.cyan(`"${pkgName}"`)),
async function infoAllow404(packageJson) {
var _pkgInfo$error;
let pkgInfo = await getPackageInfo(packageJson);
if ("E404" === (null === (_pkgInfo$error = pkgInfo.error) || void 0 === _pkgInfo$error ? void 0 : _pkgInfo$error.code)) return logger.warn("Received 404 for npm info " + chalk__default.default.cyan(`"${packageJson.name}"`)),
{

@@ -408,3 +406,3 @@ published: !1,

};
if (pkgInfo.error) throw logger.error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk__default.default.cyan(`"${pkgName}"`)}`),
if (pkgInfo.error) throw logger.error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk__default.default.cyan(`"${packageJson.name}"`)}`),
logger.error(pkgInfo.error.summary), pkgInfo.error.detail && logger.error(pkgInfo.error.detail),

@@ -455,12 +453,21 @@ new errors.ExitError(1);

const isCustomRegistry = registry => !!registry && "https://registry.npmjs.org" !== registry && "https://registry.yarnpkg.com" !== registry, getTwoFactorState = ({otp: otp, publicPackages: publicPackages}) => otp ? {
token: otp,
isRequired: Promise.resolve(!0)
} : isCI || publicPackages.some((pkg => {
var _pkg$packageJson$publ;
return isCustomRegistry(null === (_pkg$packageJson$publ = pkg.packageJson.publishConfig) || void 0 === _pkg$packageJson$publ ? void 0 : _pkg$packageJson$publ.registry);
})) || isCustomRegistry(process.env.npm_config_registry) ? {
token: null,
isRequired: Promise.resolve(!1)
} : {
token: null,
isRequired: getTokenIsRequired()
};
async function publishPackages({packages: packages, access: access, otp: otp, preState: preState, tag: tag}) {
const packagesByName = new Map(packages.map((x => [ x.packageJson.name, x ]))), publicPackages = packages.filter((pkg => !pkg.packageJson.private));
let twoFactorState = void 0 === otp ? {
token: null,
isRequired: isCI || publicPackages.some((x => x.packageJson.publishConfig && x.packageJson.publishConfig.registry && "https://registry.npmjs.org" !== x.packageJson.publishConfig.registry && "https://registry.yarnpkg.com" !== x.packageJson.publishConfig.registry)) || void 0 !== process.env.npm_config_registry && "https://registry.npmjs.org" !== process.env.npm_config_registry && "https://registry.yarnpkg.com" !== process.env.npm_config_registry ? Promise.resolve(!1) : getTokenIsRequired()
} : {
token: otp,
isRequired: Promise.resolve(!0)
};
const unpublishedPackagesInfo = await getUnpublishedPackages(publicPackages, preState);
const packagesByName = new Map(packages.map((x => [ x.packageJson.name, x ]))), publicPackages = packages.filter((pkg => !pkg.packageJson.private)), twoFactorState = getTwoFactorState({
otp: otp,
publicPackages: publicPackages
}), unpublishedPackagesInfo = await getUnpublishedPackages(publicPackages, preState);
return 0 === unpublishedPackagesInfo.length && logger.warn("No unpublished packages to publish"),

@@ -471,5 +478,5 @@ Promise.all(unpublishedPackagesInfo.map((pkgInfo => publishAPackage(packagesByName.get(pkgInfo.name), access, twoFactorState, getReleaseTag(pkgInfo, preState, tag)))));

async function publishAPackage(pkg, access, twoFactorState, tag) {
const {name: name, version: version, publishConfig: publishConfig} = pkg.packageJson, localAccess = publishConfig && publishConfig.access;
const {name: name, version: version, publishConfig: publishConfig} = pkg.packageJson, localAccess = null == publishConfig ? void 0 : publishConfig.access;
logger.info(`Publishing ${chalk__default.default.cyan(`"${name}"`)} at ${chalk__default.default.green(`"${version}"`)}`);
const publishDir = publishConfig && publishConfig.directory ? path.join(pkg.dir, publishConfig.directory) : pkg.dir;
const publishDir = (null == publishConfig ? void 0 : publishConfig.directory) ? path.join(pkg.dir, publishConfig.directory) : pkg.dir;
return {

@@ -487,9 +494,9 @@ name: name,

async function getUnpublishedPackages(packages, preState) {
const results = await Promise.all(packages.map((async pkg => {
const config = pkg.packageJson, response = await infoAllow404(config.name);
const results = await Promise.all(packages.map((async ({packageJson: packageJson}) => {
const response = await infoAllow404(packageJson);
let publishedState = "never";
return response.published && (publishedState = "published", void 0 !== preState && response.pkgInfo.versions && response.pkgInfo.versions.every((version => semver__default.default.parse(version).prerelease[0] === preState.tag)) && (publishedState = "only-pre")),
{
name: config.name,
localVersion: config.version,
name: packageJson.name,
localVersion: packageJson.version,
publishedState: publishedState,

@@ -496,0 +503,0 @@ publishedVersions: response.pkgInfo.versions || []

@@ -571,5 +571,7 @@ import meow from 'meow';

function getCorrectRegistry() {
let registry = process.env.npm_config_registry === "https://registry.yarnpkg.com" ? undefined : process.env.npm_config_registry;
return registry;
function getCorrectRegistry(packageJson) {
var _packageJson$publishC, _packageJson$publishC2;
const registry = (_packageJson$publishC = packageJson === null || packageJson === void 0 ? void 0 : (_packageJson$publishC2 = packageJson.publishConfig) === null || _packageJson$publishC2 === void 0 ? void 0 : _packageJson$publishC2.registry) !== null && _packageJson$publishC !== void 0 ? _packageJson$publishC : process.env.npm_config_registry;
return !registry || registry === "https://registry.yarnpkg.com" ? "https://registry.npmjs.org" : registry;
}

@@ -618,5 +620,5 @@

}
function getPackageInfo(pkgName) {
function getPackageInfo(packageJson) {
return npmRequestLimit(async () => {
info(`npm info ${pkgName}`); // Due to a couple of issues with yarnpkg, we also want to override the npm registry when doing
info(`npm info ${packageJson.name}`); // Due to a couple of issues with yarnpkg, we also want to override the npm registry when doing
// npm info.

@@ -628,8 +630,3 @@ // Issues: We sometimes get back cached responses, i.e old data about packages which causes

const envOverride = {
npm_config_registry: getCorrectRegistry()
};
let result = await spawn$1("npm", ["info", pkgName, "--json"], {
env: Object.assign({}, process.env, envOverride)
}); // Github package registry returns empty string when calling npm info
let result = await spawn$1("npm", ["info", packageJson.name, "--registry", getCorrectRegistry(packageJson), "--json"]); // Github package registry returns empty string when calling npm info
// for a non-existant package instead of a E404

@@ -648,7 +645,9 @@

}
async function infoAllow404(pkgName) {
let pkgInfo = await getPackageInfo(pkgName);
async function infoAllow404(packageJson) {
var _pkgInfo$error;
if (pkgInfo.error && pkgInfo.error.code === "E404") {
warn(`Received 404 for npm info ${chalk.cyan(`"${pkgName}"`)}`);
let pkgInfo = await getPackageInfo(packageJson);
if (((_pkgInfo$error = pkgInfo.error) === null || _pkgInfo$error === void 0 ? void 0 : _pkgInfo$error.code) === "E404") {
warn(`Received 404 for npm info ${chalk.cyan(`"${packageJson.name}"`)}`);
return {

@@ -661,3 +660,3 @@ published: false,

if (pkgInfo.error) {
error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk.cyan(`"${pkgName}"`)}`);
error(`Received an unknown error code: ${pkgInfo.error.code} for npm info ${chalk.cyan(`"${packageJson.name}"`)}`);
error(pkgInfo.error.summary);

@@ -762,2 +761,33 @@ if (pkgInfo.error.detail) error(pkgInfo.error.detail);

const isCustomRegistry = registry => !!registry && registry !== "https://registry.npmjs.org" && registry !== "https://registry.yarnpkg.com";
const getTwoFactorState = ({
otp,
publicPackages
}) => {
if (otp) {
return {
token: otp,
isRequired: Promise.resolve(true)
};
}
if (isCI || publicPackages.some(pkg => {
var _pkg$packageJson$publ;
return isCustomRegistry((_pkg$packageJson$publ = pkg.packageJson.publishConfig) === null || _pkg$packageJson$publ === void 0 ? void 0 : _pkg$packageJson$publ.registry);
}) || isCustomRegistry(process.env.npm_config_registry)) {
return {
token: null,
isRequired: Promise.resolve(false)
};
}
return {
token: null,
// note: we're not awaiting this here, we want this request to happen in parallel with getUnpublishedPackages
isRequired: getTokenIsRequired()
};
};
async function publishPackages({

@@ -772,10 +802,6 @@ packages,

const publicPackages = packages.filter(pkg => !pkg.packageJson.private);
let twoFactorState = otp === undefined ? {
token: null,
isRequired: isCI || publicPackages.some(x => x.packageJson.publishConfig && x.packageJson.publishConfig.registry && x.packageJson.publishConfig.registry !== "https://registry.npmjs.org" && x.packageJson.publishConfig.registry !== "https://registry.yarnpkg.com") || process.env.npm_config_registry !== undefined && process.env.npm_config_registry !== "https://registry.npmjs.org" && process.env.npm_config_registry !== "https://registry.yarnpkg.com" ? Promise.resolve(false) : // note: we're not awaiting this here, we want this request to happen in parallel with getUnpublishedPackages
getTokenIsRequired()
} : {
token: otp,
isRequired: Promise.resolve(true)
};
const twoFactorState = getTwoFactorState({
otp,
publicPackages
});
const unpublishedPackagesInfo = await getUnpublishedPackages(publicPackages, preState);

@@ -799,5 +825,5 @@

} = pkg.packageJson;
const localAccess = publishConfig && publishConfig.access;
const localAccess = publishConfig === null || publishConfig === void 0 ? void 0 : publishConfig.access;
info(`Publishing ${chalk.cyan(`"${name}"`)} at ${chalk.green(`"${version}"`)}`);
const publishDir = publishConfig && publishConfig.directory ? join(pkg.dir, publishConfig.directory) : pkg.dir;
const publishDir = (publishConfig === null || publishConfig === void 0 ? void 0 : publishConfig.directory) ? join(pkg.dir, publishConfig.directory) : pkg.dir;
const publishConfirmation = await publish(name, {

@@ -816,5 +842,6 @@ cwd: publishDir,

async function getUnpublishedPackages(packages, preState) {
const results = await Promise.all(packages.map(async pkg => {
const config = pkg.packageJson;
const response = await infoAllow404(config.name);
const results = await Promise.all(packages.map(async ({
packageJson
}) => {
const response = await infoAllow404(packageJson);
let publishedState = "never";

@@ -833,4 +860,4 @@

return {
name: config.name,
localVersion: config.version,
name: packageJson.name,
localVersion: packageJson.version,
publishedState: publishedState,

@@ -837,0 +864,0 @@ publishedVersions: response.pkgInfo.versions || []

@@ -0,5 +1,6 @@

import { PackageJSON } from "@changesets/types";
import { TwoFactorState } from "../../utils/types";
export declare function getTokenIsRequired(): Promise<boolean>;
export declare function getPackageInfo(pkgName: string): Promise<any>;
export declare function infoAllow404(pkgName: string): Promise<{
export declare function getPackageInfo(packageJson: PackageJSON): Promise<any>;
export declare function infoAllow404(packageJson: PackageJSON): Promise<{
published: boolean;

@@ -6,0 +7,0 @@ pkgInfo: any;

{
"name": "@changesets/cli",
"version": "2.16.0",
"version": "2.17.0",
"description": "Organise your package versioning and publishing to make both contributors and maintainers happy",

@@ -27,14 +27,14 @@ "bin": {

"@babel/runtime": "^7.10.4",
"@changesets/apply-release-plan": "^5.0.0",
"@changesets/assemble-release-plan": "^5.0.0",
"@changesets/config": "^1.6.0",
"@changesets/apply-release-plan": "^5.0.1",
"@changesets/assemble-release-plan": "^5.0.1",
"@changesets/config": "^1.6.1",
"@changesets/errors": "^0.1.4",
"@changesets/get-dependents-graph": "^1.2.1",
"@changesets/get-release-plan": "^3.0.0",
"@changesets/git": "^1.1.1",
"@changesets/get-dependents-graph": "^1.2.2",
"@changesets/get-release-plan": "^3.0.1",
"@changesets/git": "^1.1.2",
"@changesets/logger": "^0.0.5",
"@changesets/pre": "^1.0.6",
"@changesets/read": "^0.4.7",
"@changesets/types": "^4.0.0",
"@changesets/write": "^0.1.4",
"@changesets/pre": "^1.0.7",
"@changesets/read": "^0.5.0",
"@changesets/types": "^4.0.1",
"@changesets/write": "^0.1.5",
"@manypkg/get-packages": "^1.0.1",

@@ -41,0 +41,0 @@ "@types/semver": "^6.0.0",

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