@ckeditor/ckeditor5-dev-release-tools 62.0.0 → 62.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -54,6 +54,8 @@ import { workspaces, npm } from '@ckeditor/ckeditor5-dev-utils';
|
|
|
54
54
|
* @param {Array.<string>} [options.optionalEntryPointPackages=[]] If the entry point validator is enabled (`requireEntryPoint=true`),
|
|
55
55
|
* this array contains a list of packages that will not be checked. In other words, they do not have to define the entry point.
|
|
56
56
|
* @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
57
|
+
* @param {string} [options.workerDirectory='build'] A directory, relative to `options.cwd`, where temporary worker modules are stored.
|
|
58
|
+
* See `executeInParallel()` for details.
|
|
57
59
|
* @param {number} [options.concurrency=4] Number of CPUs that will execute the task.
|
|
58
60
|
* @param {number} [options.attempts=3] Number of attempts. After reaching 0, it won't be publishing packages again.
|
|
59
61
|
* @returns {Promise}
|
|
@@ -72,19 +74,12 @@ export default async function publishPackages( options ) {
|
|
|
72
74
|
requireEntryPoint = false,
|
|
73
75
|
optionalEntryPointPackages = [],
|
|
74
76
|
cwd = process.cwd(),
|
|
77
|
+
workerDirectory = 'build',
|
|
75
78
|
concurrency = 2,
|
|
76
79
|
attempts = 5
|
|
77
80
|
} = options;
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
// npm exchanges the OIDC token only during supported operations, such as `npm publish`, and `npm whoami`
|
|
81
|
-
// does not reflect Trusted Publishing authentication. Hence, only the token presence can be verified upfront.
|
|
82
|
-
if ( !process.env.NPM_ID_TOKEN ) {
|
|
83
|
-
throw new Error( 'The "NPM_ID_TOKEN" environment variable is required when publishing using npm Trusted Publishing (OIDC).' );
|
|
84
|
-
}
|
|
85
|
-
} else {
|
|
86
|
-
await assertNpmAuthorization( npmOwner );
|
|
87
|
-
}
|
|
82
|
+
await assertNpmAuthorization( npmOwner, { useOidc } );
|
|
88
83
|
|
|
89
84
|
// Find packages that would be published...
|
|
90
85
|
const packagePaths = await workspaces.findPathsToPackages( cwd, packagesDirectory );
|
|
@@ -127,7 +122,8 @@ export default async function publishPackages( options ) {
|
|
|
127
122
|
npmTag
|
|
128
123
|
},
|
|
129
124
|
signal,
|
|
130
|
-
concurrency
|
|
125
|
+
concurrency,
|
|
126
|
+
workerDirectory
|
|
131
127
|
} );
|
|
132
128
|
|
|
133
129
|
listrTask.output = 'Let\'s give an npm a moment for taking a breath (~10 sec)...';
|
|
@@ -19,8 +19,14 @@ const execPromise = promisify( exec );
|
|
|
19
19
|
* It supports built-in tags (e.g. `latest`, `staging`, `next`) and custom tags (e.g. `latest-v{X}`).
|
|
20
20
|
* Each operation will be retried up to 3 times in case of failure.
|
|
21
21
|
*
|
|
22
|
+
* When using npm Trusted Publishing (`useOidc`), the `npm whoami` check is replaced by verifying that the `NPM_ID_TOKEN`
|
|
23
|
+
* environment variable is set, as `npm whoami` does not reflect OIDC authentication. It requires npm 11.21.0 or newer
|
|
24
|
+
* and a trusted publisher that allows the `npm dist-tag` command.
|
|
25
|
+
*
|
|
22
26
|
* @param {object} options
|
|
23
|
-
* @param {string} options.npmOwner User that is authorized to release packages.
|
|
27
|
+
* @param {string} [options.npmOwner] User that is authorized to release packages. Required unless `useOidc` is enabled.
|
|
28
|
+
* @param {boolean} [options.useOidc=false] Whether to authorize using npm Trusted Publishing (OIDC). When enabled,
|
|
29
|
+
* the `npm whoami` authorization check is skipped and the `NPM_ID_TOKEN` environment variable must be set instead.
|
|
24
30
|
* @param {string} options.version Specifies the version of packages to reassign the tags for.
|
|
25
31
|
* @param {Array.<string>} options.packages Array of packages' names to reassign tags for.
|
|
26
32
|
* @param {string} [options.npmTag='latest'] Npm dist-tag to assign.
|
|
@@ -29,6 +35,7 @@ const execPromise = promisify( exec );
|
|
|
29
35
|
export default async function reassignNpmTags( options ) {
|
|
30
36
|
const {
|
|
31
37
|
npmOwner,
|
|
38
|
+
useOidc = false,
|
|
32
39
|
version,
|
|
33
40
|
packages,
|
|
34
41
|
npmTag = 'latest'
|
|
@@ -38,7 +45,7 @@ export default async function reassignNpmTags( options ) {
|
|
|
38
45
|
const packagesSkipped = [];
|
|
39
46
|
const packagesUpdated = [];
|
|
40
47
|
|
|
41
|
-
await assertNpmAuthorization( npmOwner );
|
|
48
|
+
await assertNpmAuthorization( npmOwner, { useOidc } );
|
|
42
49
|
|
|
43
50
|
const counter = tools.createSpinner( 'Reassigning npm tags...', { total: packages.length } );
|
|
44
51
|
counter.start();
|
|
@@ -8,10 +8,25 @@ import { tools } from '@ckeditor/ckeditor5-dev-utils';
|
|
|
8
8
|
/**
|
|
9
9
|
* Checks whether a user is logged to npm as the provided account name.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
11
|
+
* When using npm Trusted Publishing (`useOidc`), the check verifies that the `NPM_ID_TOKEN` environment variable is set
|
|
12
|
+
* instead. npm exchanges the OIDC token only during supported operations, such as `npm publish` or `npm dist-tag`,
|
|
13
|
+
* and `npm whoami` does not reflect Trusted Publishing authentication.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} [npmOwner] Expected npm account name that should be logged into npm. Required unless `useOidc` is enabled.
|
|
16
|
+
* @param {object} [options={}]
|
|
17
|
+
* @param {boolean} [options.useOidc=false] Whether to verify the npm Trusted Publishing (OIDC) setup instead of the npm account.
|
|
12
18
|
* @returns {Promise}
|
|
13
19
|
*/
|
|
14
|
-
export default async function assertNpmAuthorization( npmOwner ) {
|
|
20
|
+
export default async function assertNpmAuthorization( npmOwner, { useOidc = false } = {} ) {
|
|
21
|
+
if ( useOidc ) {
|
|
22
|
+
// Only the token presence can be verified upfront.
|
|
23
|
+
if ( !process.env.NPM_ID_TOKEN ) {
|
|
24
|
+
throw new Error( 'The "NPM_ID_TOKEN" environment variable is required when using npm Trusted Publishing (OIDC).' );
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
return tools.shExec( 'npm whoami', { verbosity: 'error', async: true } )
|
|
16
31
|
.then( npmCurrentUser => {
|
|
17
32
|
if ( npmOwner !== npmCurrentUser.trim() ) {
|
|
@@ -31,6 +31,9 @@ const WORKER_SCRIPT = new URL( './parallelworker.js', import.meta.url );
|
|
|
31
31
|
* @param {ExecuteInParallelPackagesDirectoryFilter|null} [options.packagesDirectoryFilter=null] An optional callback allowing filtering out
|
|
32
32
|
* directories/packages that should not be touched by the task.
|
|
33
33
|
* @param {string} [options.cwd=process.cwd()] Current working directory from which all paths will be resolved.
|
|
34
|
+
* @param {string} [options.workerDirectory='build'] A directory, relative to `options.cwd`, where temporary worker modules are stored.
|
|
35
|
+
* It must be inside the project so workers can resolve dependencies from `node_modules`. The default `build` directory is usually ignored
|
|
36
|
+
* by git, preventing leftover files from polluting the working tree.
|
|
34
37
|
* @param {number} [options.concurrency=require( 'os' ).cpus().length / 2] Number of CPUs that will execute the task.
|
|
35
38
|
* @returns {Promise}
|
|
36
39
|
*/
|
|
@@ -43,6 +46,7 @@ export default async function executeInParallel( options ) {
|
|
|
43
46
|
taskOptions = null,
|
|
44
47
|
packagesDirectoryFilter = null,
|
|
45
48
|
cwd = process.cwd(),
|
|
49
|
+
workerDirectory = 'build',
|
|
46
50
|
concurrency = os.cpus().length / 2
|
|
47
51
|
} = options;
|
|
48
52
|
|
|
@@ -53,7 +57,10 @@ export default async function executeInParallel( options ) {
|
|
|
53
57
|
|
|
54
58
|
const packagesInThreads = getPackagesGroupedByThreads( packagesToProcess, concurrencyAsInteger );
|
|
55
59
|
|
|
56
|
-
const
|
|
60
|
+
const callbackModuleDirectory = upath.join( cwd, workerDirectory );
|
|
61
|
+
const callbackModule = upath.join( callbackModuleDirectory, crypto.randomUUID() + '.mjs' );
|
|
62
|
+
|
|
63
|
+
await fs.mkdir( callbackModuleDirectory, { recursive: true } );
|
|
57
64
|
await fs.writeFile( callbackModule, `export default ${ taskToExecute };`, 'utf-8' );
|
|
58
65
|
|
|
59
66
|
const onPackageDone = progressFactory( listrTask, packagesToProcess.length );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-dev-release-tools",
|
|
3
|
-
"version": "62.
|
|
3
|
+
"version": "62.2.0",
|
|
4
4
|
"description": "Tools used for releasing CKEditor 5 and related packages.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"lib"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ckeditor/ckeditor5-dev-utils": "^62.
|
|
25
|
+
"@ckeditor/ckeditor5-dev-utils": "^62.2.0",
|
|
26
26
|
"@octokit/rest": "^22.0.1",
|
|
27
27
|
"cli-columns": "^4.0.0",
|
|
28
28
|
"glob": "^13.0.6",
|