@ckeditor/ckeditor5-dev-release-tools
Advanced tools
Comparing version 45.0.5 to 45.0.6
@@ -18,10 +18,13 @@ /** | ||
/** | ||
* The purpose of the script is to validate the packages prepared for the release and then release them on npm. | ||
* The purpose of the script is to publish the prepared packages. However, before, it executes a few checks that | ||
* prevent from publishing an incomplete package. | ||
* | ||
* The validation contains the following steps in each package: | ||
* - User must be logged to npm on the specified account. | ||
* - The package directory must contain `package.json` file. | ||
* - All other files expected to be released must exist in the package directory. | ||
* - The npm tag must match the tag calculated from the package version. | ||
* The validation contains the following steps: | ||
* | ||
* - A user (a CLI session) must be logged to npm on the specified account (`npmOwner`). | ||
* - A package directory must contain `package.json` file. | ||
* - All files defined in the `optionalEntryPointPackages` option must exist in a package directory. | ||
* - An npm tag (dist-tag) must match the tag calculated from the package version. | ||
* A stable release can be also published as `next` or `staging. | ||
* | ||
* When the validation for each package passes, packages are published on npm. Optional callback is called for confirmation whether to | ||
@@ -31,3 +34,3 @@ * continue. | ||
* If a package has already been published, the script does not try to publish it again. Instead, it treats the package as published. | ||
* Whenever a communication between the script and npm fails, it tries to re-publish a package (up to three attempts). | ||
* Whenever a communication between the script and npm fails, it tries to re-publish a package (up to five attempts). | ||
* | ||
@@ -68,14 +71,33 @@ * @param {object} options | ||
concurrency = 2, | ||
attempts = 3 | ||
attempts = 5 | ||
} = options; | ||
const remainingAttempts = attempts - 1; | ||
await assertNpmAuthorization( npmOwner ); | ||
// Find packages that would be published... | ||
const packagePaths = await findPathsToPackages( cwd, packagesDirectory ); | ||
await assertPackages( packagePaths, { requireEntryPoint, optionalEntryPointPackages } ); | ||
await assertFilesToPublish( packagePaths, optionalEntries ); | ||
await assertNpmTag( packagePaths, npmTag ); | ||
// ...and filter out those that have already been processed. | ||
// In other words, check whether a version per package (it's read from a `package.json` file) | ||
// is not available. Otherwise, a package is ignored. | ||
await removeAlreadyPublishedPackages( packagePaths ); | ||
// Once again, find packages to publish after the filtering operation. | ||
const packagesToProcess = await findPathsToPackages( cwd, packagesDirectory ); | ||
if ( !packagesToProcess.length ) { | ||
listrTask.output = 'All packages have been published.'; | ||
return Promise.resolve(); | ||
} | ||
// No more attempts. Abort. | ||
if ( attempts <= 0 ) { | ||
throw new Error( 'Some packages could not be published.' ); | ||
} | ||
await assertPackages( packagesToProcess, { requireEntryPoint, optionalEntryPointPackages } ); | ||
await assertFilesToPublish( packagesToProcess, optionalEntries ); | ||
await assertNpmTag( packagesToProcess, npmTag ); | ||
const shouldPublishPackages = confirmationCallback ? await confirmationCallback() : true; | ||
@@ -87,4 +109,2 @@ | ||
await removeAlreadyPublishedPackages( packagePaths ); | ||
await executeInParallel( { | ||
@@ -102,35 +122,13 @@ cwd, | ||
const packagePathsAfterPublishing = await findPathsToPackages( cwd, packagesDirectory ); | ||
// All packages have been published. No need for re-executing. | ||
if ( !packagePathsAfterPublishing.length ) { | ||
return Promise.resolve(); | ||
} | ||
// No more attempts. Abort. | ||
if ( remainingAttempts <= 0 ) { | ||
throw new Error( 'Some packages could not be published.' ); | ||
} | ||
listrTask.output = 'Let\'s give an npm a moment for taking a breath (~10 sec)...'; | ||
// Let's give an npm a moment for taking a breath... | ||
await wait( 1000 * 10 ); | ||
listrTask.output = 'Done. Let\'s continue.'; | ||
listrTask.output = 'Done. Let\'s continue. Re-executing.'; | ||
// ...and try again. | ||
return publishPackages( { | ||
packagesDirectory, | ||
npmOwner, | ||
listrTask, | ||
signal, | ||
npmTag, | ||
optionalEntries, | ||
requireEntryPoint, | ||
optionalEntryPointPackages, | ||
cwd, | ||
concurrency, | ||
...options, | ||
confirmationCallback: null, // Do not ask again if already here. | ||
attempts: remainingAttempts | ||
attempts: attempts - 1 | ||
} ); | ||
@@ -137,0 +135,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
import pacote from 'pacote'; | ||
import { manifest } from './pacotecacheless.js'; | ||
@@ -19,5 +19,5 @@ /** | ||
export default async function checkVersionAvailability( version, packageName ) { | ||
return pacote.manifest( `${ packageName }@${ version }`, { cache: null, preferOnline: true } ) | ||
return manifest( `${ packageName }@${ version }` ) | ||
.then( () => { | ||
// If `pacote.manifest` resolves, a package with the given version exists. | ||
// If `manifest` resolves, a package with the given version exists. | ||
return false; | ||
@@ -24,0 +24,0 @@ } ) |
@@ -7,3 +7,3 @@ /** | ||
import semver from 'semver'; | ||
import pacote from 'pacote'; | ||
import { manifest } from './pacotecacheless.js'; | ||
@@ -19,3 +19,3 @@ /** | ||
export default async function isVersionPublishableForTag( packageName, version, npmTag ) { | ||
const npmVersion = await pacote.manifest( `${ packageName }@${ npmTag }`, { cache: null, preferOnline: true } ) | ||
const npmVersion = await manifest( `${ packageName }@${ npmTag }` ) | ||
.then( ( { version } ) => version ) | ||
@@ -22,0 +22,0 @@ // An `npmTag` does not exist, or it's a first release of a package. |
@@ -7,3 +7,3 @@ /** | ||
import { tools } from '@ckeditor/ckeditor5-dev-utils'; | ||
import pacote from 'pacote'; | ||
import { packument } from './pacotecacheless.js'; | ||
import getChangelog from './getchangelog.js'; | ||
@@ -42,3 +42,3 @@ import getPackageJson from './getpackagejson.js'; | ||
return pacote.packument( packageName, { cache: null, preferOnline: true } ) | ||
return packument( packageName ) | ||
.then( result => { | ||
@@ -45,0 +45,0 @@ const lastVersion = Object.keys( result.versions ) |
{ | ||
"name": "@ckeditor/ckeditor5-dev-release-tools", | ||
"version": "45.0.5", | ||
"version": "45.0.6", | ||
"description": "Tools used for releasing CKEditor 5 and related packages.", | ||
@@ -25,3 +25,3 @@ "keywords": [], | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-dev-utils": "^45.0.5", | ||
"@ckeditor/ckeditor5-dev-utils": "^45.0.6", | ||
"@octokit/rest": "^21.0.0", | ||
@@ -28,0 +28,0 @@ "chalk": "^5.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155788
59
3861
16