@lerna-lite/publish 1.16.2 → 2.0.0-alpha.2

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.
Files changed (57) hide show
  1. package/README.md +9 -44
  2. package/dist/index.d.ts +3 -3
  3. package/dist/index.js +3 -6
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/create-temp-licenses.js +7 -12
  6. package/dist/lib/create-temp-licenses.js.map +1 -1
  7. package/dist/lib/fetch-config.js +3 -8
  8. package/dist/lib/fetch-config.js.map +1 -1
  9. package/dist/lib/get-current-sha.js +6 -11
  10. package/dist/lib/get-current-sha.js.map +1 -1
  11. package/dist/lib/get-current-tags.js +7 -12
  12. package/dist/lib/get-current-tags.js.map +1 -1
  13. package/dist/lib/get-npm-username.js +11 -15
  14. package/dist/lib/get-npm-username.js.map +1 -1
  15. package/dist/lib/get-packages-without-license.js +3 -8
  16. package/dist/lib/get-packages-without-license.js.map +1 -1
  17. package/dist/lib/get-packed.d.ts +1 -1
  18. package/dist/lib/get-packed.js +12 -16
  19. package/dist/lib/get-packed.js.map +1 -1
  20. package/dist/lib/get-profile-data.js +4 -9
  21. package/dist/lib/get-profile-data.js.map +1 -1
  22. package/dist/lib/get-tagged-packages.js +8 -13
  23. package/dist/lib/get-tagged-packages.js.map +1 -1
  24. package/dist/lib/get-two-factor-auth-required.js +7 -11
  25. package/dist/lib/get-two-factor-auth-required.js.map +1 -1
  26. package/dist/lib/get-unpublished-packages.js +13 -21
  27. package/dist/lib/get-unpublished-packages.js.map +1 -1
  28. package/dist/lib/get-whoami.js +4 -9
  29. package/dist/lib/get-whoami.js.map +1 -1
  30. package/dist/lib/git-checkout.js +5 -10
  31. package/dist/lib/git-checkout.js.map +1 -1
  32. package/dist/lib/index.d.ts +19 -19
  33. package/dist/lib/index.js +19 -22
  34. package/dist/lib/index.js.map +1 -1
  35. package/dist/lib/log-packed.d.ts +1 -1
  36. package/dist/lib/log-packed.js +28 -34
  37. package/dist/lib/log-packed.js.map +1 -1
  38. package/dist/lib/npm-dist-tag.d.ts +1 -1
  39. package/dist/lib/npm-dist-tag.js +21 -30
  40. package/dist/lib/npm-dist-tag.js.map +1 -1
  41. package/dist/lib/npm-publish.d.ts +1 -1
  42. package/dist/lib/npm-publish.js +18 -24
  43. package/dist/lib/npm-publish.js.map +1 -1
  44. package/dist/lib/override-publish-config.js +4 -8
  45. package/dist/lib/override-publish-config.js.map +1 -1
  46. package/dist/lib/pack-directory.d.ts +1 -1
  47. package/dist/lib/pack-directory.js +22 -27
  48. package/dist/lib/pack-directory.js.map +1 -1
  49. package/dist/lib/remove-temp-licenses.js +4 -9
  50. package/dist/lib/remove-temp-licenses.js.map +1 -1
  51. package/dist/lib/verify-npm-package-access.js +9 -14
  52. package/dist/lib/verify-npm-package-access.js.map +1 -1
  53. package/dist/models/index.js +1 -2
  54. package/dist/publish-command.d.ts +0 -1
  55. package/dist/publish-command.js +121 -160
  56. package/dist/publish-command.js.map +1 -1
  57. package/package.json +38 -21
@@ -1,40 +1,36 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PublishCommand = exports.factory = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const glob_1 = tslib_1.__importDefault(require("glob"));
7
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
8
- const os_1 = tslib_1.__importDefault(require("os"));
9
- const path_1 = tslib_1.__importDefault(require("path"));
10
- const crypto_1 = tslib_1.__importDefault(require("crypto"));
11
- const p_map_1 = tslib_1.__importDefault(require("p-map"));
12
- const p_pipe_1 = tslib_1.__importDefault(require("p-pipe"));
13
- const semver_1 = tslib_1.__importDefault(require("semver"));
14
- const temp_dir_1 = tslib_1.__importDefault(require("temp-dir"));
15
- const version_1 = require("@lerna-lite/version");
16
- const core_1 = require("@lerna-lite/core");
17
- const get_current_tags_1 = require("./lib/get-current-tags");
18
- const get_tagged_packages_1 = require("./lib/get-tagged-packages");
19
- const get_unpublished_packages_1 = require("./lib/get-unpublished-packages");
20
- const get_npm_username_1 = require("./lib/get-npm-username");
21
- const verify_npm_package_access_1 = require("./lib/verify-npm-package-access");
22
- const get_two_factor_auth_required_1 = require("./lib/get-two-factor-auth-required");
23
- const get_current_sha_1 = require("./lib/get-current-sha");
24
- const git_checkout_1 = require("./lib/git-checkout");
25
- const pack_directory_1 = require("./lib/pack-directory");
26
- const npm_publish_1 = require("./lib/npm-publish");
27
- const log_packed_1 = require("./lib/log-packed");
28
- const npm_dist_tag_1 = require("./lib/npm-dist-tag");
29
- const override_publish_config_1 = require("./lib/override-publish-config");
30
- const remove_temp_licenses_1 = require("./lib/remove-temp-licenses");
31
- const create_temp_licenses_1 = require("./lib/create-temp-licenses");
32
- const get_packages_without_license_1 = require("./lib/get-packages-without-license");
33
- function factory(argv) {
1
+ import chalk from 'chalk';
2
+ import { glob } from 'glob';
3
+ import { outputFileSync, removeSync } from 'fs-extra/esm';
4
+ import { EOL } from 'node:os';
5
+ import { join, relative } from 'node:path';
6
+ import crypto from 'crypto';
7
+ import normalizePath from 'normalize-path';
8
+ import pMap from 'p-map';
9
+ import pPipe from 'p-pipe';
10
+ import semver from 'semver';
11
+ import tempDir from 'temp-dir';
12
+ import { getOneTimePassword, VersionCommand } from '@lerna-lite/version';
13
+ import { collectUpdates, Command, createRunner, deleteComplexObjectProp, describeRef, logOutput, npmConf, prereleaseIdFromVersion, promptConfirmation, pulseTillDone, runTopologically, throwIfUncommitted, ValidationError, } from '@lerna-lite/core';
14
+ import { getCurrentTags } from './lib/get-current-tags.js';
15
+ import { getTaggedPackages } from './lib/get-tagged-packages.js';
16
+ import { getUnpublishedPackages } from './lib/get-unpublished-packages.js';
17
+ import { getNpmUsername } from './lib/get-npm-username.js';
18
+ import { verifyNpmPackageAccess } from './lib/verify-npm-package-access.js';
19
+ import { getTwoFactorAuthRequired } from './lib/get-two-factor-auth-required.js';
20
+ import { getCurrentSHA } from './lib/get-current-sha.js';
21
+ import { gitCheckout } from './lib/git-checkout.js';
22
+ import { packDirectory } from './lib/pack-directory.js';
23
+ import { npmPublish } from './lib/npm-publish.js';
24
+ import { logPacked } from './lib/log-packed.js';
25
+ import { add, remove } from './lib/npm-dist-tag.js';
26
+ import { overridePublishConfig } from './lib/override-publish-config.js';
27
+ import { removeTempLicenses } from './lib/remove-temp-licenses.js';
28
+ import { createTempLicenses } from './lib/create-temp-licenses.js';
29
+ import { getPackagesWithoutLicense } from './lib/get-packages-without-license.js';
30
+ export function factory(argv) {
34
31
  return new PublishCommand(argv);
35
32
  }
36
- exports.factory = factory;
37
- class PublishCommand extends core_1.Command {
33
+ export class PublishCommand extends Command {
38
34
  get otherCommandConfigs() {
39
35
  // back-compat
40
36
  return ['version'];
@@ -70,7 +66,7 @@ class PublishCommand extends core_1.Command {
70
66
  // prettier-ignore
71
67
  exact, gitHead, gitReset, tagVersionPrefix = 'v', verifyAccess, } = this.options;
72
68
  if (this.requiresGit && gitHead) {
73
- throw new core_1.ValidationError('EGITHEAD', '--git-head is only allowed with "from-package" positional');
69
+ throw new ValidationError('EGITHEAD', '--git-head is only allowed with "from-package" positional');
74
70
  }
75
71
  // https://docs.npmjs.com/misc/config#save-prefix
76
72
  this.savePrefix = exact ? '' : '^';
@@ -80,7 +76,7 @@ class PublishCommand extends core_1.Command {
80
76
  // inverted boolean options are only respected if prefixed with `--no-`, e.g. `--no-verify-access`
81
77
  this.gitReset = gitReset !== false;
82
78
  // consumed by npm-registry-fetch (via libnpmpublish)
83
- this.npmSession = crypto_1.default.randomBytes(8).toString('hex');
79
+ this.npmSession = crypto.randomBytes(8).toString('hex');
84
80
  this.verifyAccess = verifyAccess;
85
81
  }
86
82
  get userAgent() {
@@ -94,23 +90,16 @@ class PublishCommand extends core_1.Command {
94
90
  if (this.options.graphType === 'dependencies') {
95
91
  this.logger.warn('graph-type', '--graph-type=dependencies is deprecated and will be removed in the next major version of lerna-lite. If you have a use-case you feel requires it please open an issue to discuss: https://github.com/lerna/lerna/issues/new/choose');
96
92
  }
97
- if (this.options.workspaceStrictMatch === false) {
98
- this.logger.warn('deprecation', 'Providing --no-workspace-strict-match is deprecated and will be removed in future version, we will make "workspace:" protocol strict matching in every case.');
99
- }
100
93
  if (this.options.buildMetadata && this.options.canary) {
101
- throw new core_1.ValidationError('ENOTSATISFIED', 'Cannot use --build-metadata in conjunction with --canary option.');
94
+ throw new ValidationError('ENOTSATISFIED', 'Cannot use --build-metadata in conjunction with --canary option.');
102
95
  }
103
96
  else if (this.options.canary) {
104
97
  this.logger.info('canary', 'enabled');
105
98
  }
106
- // @deprecated, to be removed in next major
107
- if (this.options.requireScripts) {
108
- this.logger.info('require-scripts', 'enabled');
109
- }
110
99
  // npmSession and user-agent are consumed by npm-registry-fetch (via libnpmpublish)
111
100
  this.logger.verbose('session', this.npmSession);
112
101
  this.logger.verbose('user-agent', this.userAgent);
113
- this.conf = (0, core_1.npmConf)({
102
+ this.conf = npmConf({
114
103
  lernaCommand: 'publish',
115
104
  _auth: this.options.legacyAuth,
116
105
  npmSession: this.npmSession,
@@ -138,7 +127,7 @@ class PublishCommand extends core_1.Command {
138
127
  if (this.hasRootedLeaf) {
139
128
  this.logger.info('publish', 'rooted leaf detected, skipping synthetic root lifecycles');
140
129
  }
141
- this.runPackageLifecycle = (0, core_1.createRunner)(this.options);
130
+ this.runPackageLifecycle = createRunner(this.options);
142
131
  // don't execute recursively if run from a poorly-named script
143
132
  this.runRootLifecycle = /^(pre|post)?publish$/.test(process.env.npm_lifecycle_event || '')
144
133
  ? (stage) => this.logger.warn('lifecycle', 'Skipping root %j because it has already been called', stage)
@@ -154,7 +143,7 @@ class PublishCommand extends core_1.Command {
154
143
  chain = chain.then(() => this.detectCanaryVersions());
155
144
  }
156
145
  else {
157
- chain = chain.then(() => new version_1.VersionCommand(this.argv));
146
+ chain = chain.then(() => new VersionCommand(this.argv));
158
147
  }
159
148
  return chain.then((result) => {
160
149
  if (!result) {
@@ -186,7 +175,6 @@ class PublishCommand extends core_1.Command {
186
175
  });
187
176
  }
188
177
  async execute() {
189
- var _a;
190
178
  this.enableProgressBar();
191
179
  this.logger.info('publish', 'Publishing packages to npm...');
192
180
  await this.prepareRegistryActions();
@@ -212,15 +200,16 @@ class PublishCommand extends core_1.Command {
212
200
  if (this.options.tempTag) {
213
201
  await this.npmUpdateAsLatest();
214
202
  }
215
- const count = (_a = this.publishedPackages) === null || _a === void 0 ? void 0 : _a.length;
203
+ const count = this.publishedPackages?.length;
216
204
  const publishedPackagesSorted = this.publishedPackages.sort((a, b) => a.name.localeCompare(b.name));
217
205
  if (!count) {
218
206
  this.logger.success('All packages have already been published.');
219
207
  return;
220
208
  }
221
- (0, core_1.logOutput)('Successfully published:');
209
+ logOutput('Successfully published:');
222
210
  if (this.options.summaryFile !== undefined) {
223
211
  // create a json object and output it to a file location.
212
+ //prettier-ignore
224
213
  const filePath = this.options.summaryFile
225
214
  ? `${this.options.summaryFile}/lerna-publish-summary.json`
226
215
  : './lerna-publish-summary.json';
@@ -230,38 +219,38 @@ class PublishCommand extends core_1.Command {
230
219
  version: pkg.version,
231
220
  };
232
221
  });
233
- (0, core_1.logOutput)(jsonObject);
222
+ logOutput(jsonObject);
234
223
  try {
235
- fs_extra_1.default.outputFileSync(filePath, JSON.stringify(jsonObject));
236
- (0, core_1.logOutput)('Publish summary created: ', filePath);
224
+ outputFileSync(filePath, JSON.stringify(jsonObject));
225
+ logOutput('Publish summary created: ', filePath);
237
226
  }
238
227
  catch (error) {
239
- (0, core_1.logOutput)('Failed to create the summary report', error);
228
+ logOutput('Failed to create the summary report', error);
240
229
  }
241
230
  }
242
231
  else {
243
232
  const message = publishedPackagesSorted.map((pkg) => ` - ${pkg.name}@${pkg.version}`);
244
- (0, core_1.logOutput)(message.join(os_1.default.EOL));
233
+ logOutput(message.join(EOL));
245
234
  }
246
235
  // optionally cleanup temp packed files after publish, opt-in option
247
236
  if (this.options.cleanupTempFiles) {
248
- (0, glob_1.default)(path_1.default.join(temp_dir_1.default, '/lerna-*'), (_err, deleteFolders) => {
237
+ glob(normalizePath(join(tempDir, '/lerna-*'))).then((deleteFolders) => {
249
238
  // delete silently all files/folders that startsWith "lerna-"
250
- deleteFolders.forEach((folder) => fs_extra_1.default.removeSync(folder));
239
+ deleteFolders.forEach((folder) => removeSync(folder));
251
240
  this.logger.verbose('publish', `Found ${deleteFolders.length} temp folders to cleanup after publish.`);
252
241
  });
253
242
  }
254
243
  this.logger.success('published', '%d %s', count, count === 1 ? 'package' : 'packages');
255
244
  }
256
245
  verifyWorkingTreeClean() {
257
- return (0, core_1.describeRef)(this.execOpts, undefined, this.options.dryRun).then(core_1.throwIfUncommitted);
246
+ return describeRef(this.execOpts, undefined, this.options.dryRun).then(throwIfUncommitted);
258
247
  }
259
248
  detectFromGit() {
260
249
  const matchingPattern = this.project.isIndependent() ? `*@*` : `${this.tagPrefix}*.*.*`;
261
250
  let chain = Promise.resolve();
262
251
  // attempting to publish a tagged release with local changes is not allowed
263
252
  chain = chain.then(() => this.verifyWorkingTreeClean());
264
- chain = chain.then(() => (0, get_current_tags_1.getCurrentTags)(this.execOpts, matchingPattern));
253
+ chain = chain.then(() => getCurrentTags(this.execOpts, matchingPattern));
265
254
  chain = chain.then((taggedPackageNames) => {
266
255
  if (!taggedPackageNames.length) {
267
256
  this.logger.notice('from-git', 'No tagged release found. You might not have fetched tags.');
@@ -270,7 +259,7 @@ class PublishCommand extends core_1.Command {
270
259
  if (this.project.isIndependent()) {
271
260
  return taggedPackageNames.map((name) => this.packageGraph.get(name));
272
261
  }
273
- return (0, get_tagged_packages_1.getTaggedPackages)(this.packageGraph, this.project.rootPath, this.execOpts);
262
+ return getTaggedPackages(this.packageGraph, this.project.rootPath, this.execOpts);
274
263
  });
275
264
  // private packages are never published, full stop.
276
265
  chain = chain.then((updates) => updates.filter((node) => !node.pkg.private));
@@ -302,7 +291,7 @@ class PublishCommand extends core_1.Command {
302
291
  }
303
292
  });
304
293
  // private packages are already omitted by getUnpublishedPackages()
305
- chain = chain.then(() => (0, get_unpublished_packages_1.getUnpublishedPackages)(this.packageGraph, this.conf.snapshot));
294
+ chain = chain.then(() => getUnpublishedPackages(this.packageGraph, this.conf.snapshot));
306
295
  chain = chain.then((unpublished) => {
307
296
  if (!unpublished.length) {
308
297
  this.logger.notice('from-package', 'No unpublished release found');
@@ -340,31 +329,30 @@ class PublishCommand extends core_1.Command {
340
329
  }
341
330
  });
342
331
  const isIndependent = this.project.isIndependent();
332
+ const describeTag = this.project.config.describeTag;
343
333
  // find changed packages since last release, if any
344
- chain = chain.then(() => {
345
- var _a, _b;
346
- return (0, core_1.collectUpdates)((_b = (_a = this.packageGraph) === null || _a === void 0 ? void 0 : _a.rawPackageList) !== null && _b !== void 0 ? _b : [], this.packageGraph, this.execOpts, {
347
- bump: 'prerelease',
348
- canary: true,
349
- ignoreChanges,
350
- forcePublish,
351
- includeMergedTags,
352
- isIndependent,
353
- // private packages are never published, don't bother describing their refs.
354
- }, this.options.dryRun).filter((node) => !node.pkg.private);
355
- });
334
+ chain = chain.then(() => collectUpdates(this.packageGraph?.rawPackageList ?? [], this.packageGraph, this.execOpts, {
335
+ bump: 'prerelease',
336
+ canary: true,
337
+ ignoreChanges,
338
+ forcePublish,
339
+ includeMergedTags,
340
+ isIndependent,
341
+ describeTag,
342
+ // private packages are never published, don't bother describing their refs.
343
+ }, this.options.dryRun).filter((node) => !node.pkg.private));
356
344
  // prettier-ignore
357
345
  const makeVersion = (fallback) => ({ lastVersion = fallback, refCount, sha }) => {
358
346
  // the next version is bumped without concern for preid or current index
359
347
  // prettier-ignore
360
- const nextVersion = semver_1.default.inc(lastVersion.replace(this.tagPrefix, ''), release.replace('pre', ''));
348
+ const nextVersion = semver.inc(lastVersion.replace(this.tagPrefix, ''), release.replace('pre', ''));
361
349
  // semver.inc() starts a new prerelease at .0, git describe starts at .1
362
350
  // and build metadata is always ignored when comparing dependency ranges
363
351
  return `${nextVersion}-${preid}.${Math.max(0, refCount - 1)}+${sha}`;
364
352
  };
365
353
  if (isIndependent) {
366
354
  // each package is described against its tags only
367
- chain = chain.then((updates) => (0, p_map_1.default)(updates, (node) => (0, core_1.describeRef)({
355
+ chain = chain.then((updates) => pMap(updates, (node) => describeRef({
368
356
  match: `${node.name}@*`,
369
357
  cwd,
370
358
  }, includeMergedTags, this.options.dryRun)
@@ -377,7 +365,7 @@ class PublishCommand extends core_1.Command {
377
365
  }
378
366
  else {
379
367
  // all packages are described against the last tag
380
- chain = chain.then((updates) => (0, core_1.describeRef)({
368
+ chain = chain.then((updates) => describeRef({
381
369
  match: `${this.tagPrefix}*.*.*`,
382
370
  cwd,
383
371
  }, includeMergedTags, this.options.dryRun)
@@ -396,24 +384,23 @@ class PublishCommand extends core_1.Command {
396
384
  }));
397
385
  }
398
386
  confirmPublish() {
399
- var _a, _b, _c;
400
- const count = (_a = this.packagesToPublish) === null || _a === void 0 ? void 0 : _a.length;
401
- const message = (_c = (_b = this.packagesToPublish) === null || _b === void 0 ? void 0 : _b.map((pkg) => { var _a; return ` - ${pkg.name} => ${(_a = this.updatesVersions) === null || _a === void 0 ? void 0 : _a.get(pkg.name)}`; })) !== null && _c !== void 0 ? _c : [];
402
- (0, core_1.logOutput)('');
403
- (0, core_1.logOutput)(`Found ${count} ${count === 1 ? 'package' : 'packages'} to publish:`);
404
- (0, core_1.logOutput)(message.join(os_1.default.EOL));
405
- (0, core_1.logOutput)('');
387
+ const count = this.packagesToPublish?.length;
388
+ const message = this.packagesToPublish?.map((pkg) => ` - ${pkg.name} => ${this.updatesVersions?.get(pkg.name)}`) ?? [];
389
+ logOutput('');
390
+ logOutput(`Found ${count} ${count === 1 ? 'package' : 'packages'} to publish:`);
391
+ logOutput(message.join(EOL));
392
+ logOutput('');
406
393
  if (this.options.yes) {
407
394
  this.logger.info('auto-confirmed', '');
408
395
  return true;
409
396
  }
410
- let confirmMessage = this.options.dryRun ? chalk_1.default.bgMagenta('[dry-run]') : '';
397
+ let confirmMessage = this.options.dryRun ? chalk.bgMagenta('[dry-run]') : '';
411
398
  confirmMessage += ' Are you sure you want to publish these packages?';
412
- return (0, core_1.promptConfirmation)(confirmMessage.trim());
399
+ return promptConfirmation(confirmMessage.trim());
413
400
  }
414
401
  prepareLicenseActions() {
415
402
  return Promise.resolve()
416
- .then(() => { var _a; return (0, get_packages_without_license_1.getPackagesWithoutLicense)(this.project, (_a = this.packagesToPublish) !== null && _a !== void 0 ? _a : []); })
403
+ .then(() => getPackagesWithoutLicense(this.project, this.packagesToPublish ?? []))
417
404
  .then((packagesWithoutLicense) => {
418
405
  if (packagesWithoutLicense.length && !this.project.licensePath) {
419
406
  this.packagesToBeLicensed = [];
@@ -439,23 +426,22 @@ class PublishCommand extends core_1.Command {
439
426
  this.logger.notice('', `Make sure you're authenticated properly "\\_(ツ)_ /"`);
440
427
  return chain;
441
428
  }
442
- /* istanbul ignore if */
429
+ /* c8 ignore next 3 */
443
430
  if (process.env.LERNA_INTEGRATION) {
444
431
  return chain;
445
432
  }
446
433
  if (this.verifyAccess) {
447
434
  // validate user has valid npm credentials first,
448
435
  // by far the most common form of failed execution
449
- chain = chain.then(() => (0, get_npm_username_1.getNpmUsername)(this.conf.snapshot));
436
+ chain = chain.then(() => getNpmUsername(this.conf.snapshot));
450
437
  chain = chain.then((username) => {
451
- var _a;
452
438
  // if no username was retrieved, don't bother validating
453
439
  if (username) {
454
- return (0, verify_npm_package_access_1.verifyNpmPackageAccess)((_a = this.packagesToPublish) !== null && _a !== void 0 ? _a : [], username, this.conf.snapshot);
440
+ return verifyNpmPackageAccess(this.packagesToPublish ?? [], username, this.conf.snapshot);
455
441
  }
456
442
  });
457
443
  // read profile metadata to determine if account-level 2FA is enabled
458
- chain = chain.then(() => (0, get_two_factor_auth_required_1.getTwoFactorAuthRequired)(this.conf.snapshot));
444
+ chain = chain.then(() => getTwoFactorAuthRequired(this.conf.snapshot));
459
445
  chain = chain.then((isRequired) => {
460
446
  // notably, this still doesn't handle package-level 2FA requirements
461
447
  this.twoFactorAuthRequired = isRequired;
@@ -464,14 +450,13 @@ class PublishCommand extends core_1.Command {
464
450
  return chain;
465
451
  }
466
452
  updateCanaryVersions() {
467
- return (0, p_map_1.default)(this.updates, (node) => {
468
- var _a, _b, _c;
469
- node.pkg.set('version', (_a = this.updatesVersions) === null || _a === void 0 ? void 0 : _a.get(node.name));
453
+ return pMap(this.updates, (node) => {
454
+ node.pkg.set('version', this.updatesVersions?.get(node.name));
470
455
  for (const [depName, resolved] of node.localDependencies) {
471
456
  // other canary versions need to be updated, non-canary is a no-op
472
- const depVersion = ((_b = this.updatesVersions) === null || _b === void 0 ? void 0 : _b.get(depName)) || ((_c = this.packageGraph) === null || _c === void 0 ? void 0 : _c.get(depName).pkg.version);
457
+ const depVersion = this.updatesVersions?.get(depName) || this.packageGraph?.get(depName).pkg.version;
473
458
  // it no longer matters if we mutate the shared Package instance
474
- node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.options.workspaceStrictMatch, this.commandName);
459
+ node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.commandName);
475
460
  }
476
461
  // writing changes to disk handled in serializeChanges()
477
462
  });
@@ -483,18 +468,17 @@ class PublishCommand extends core_1.Command {
483
468
  */
484
469
  applyPublishConfigOverrides() {
485
470
  // potentially apply any packages that might have publishConfig overrides
486
- return (0, p_map_1.default)(this.updates, (node) => (0, override_publish_config_1.overridePublishConfig)(node.pkg.manifest));
471
+ return pMap(this.updates, (node) => overridePublishConfig(node.pkg.manifest));
487
472
  }
488
473
  resolveLocalDependencyLinks() {
489
474
  // resolve relative file: links to their actual version range
490
475
  const updatesWithLocalLinks = this.updates.filter((node) => Array.from(node.localDependencies.values()).some((resolved) => resolved.type === 'directory'));
491
- return (0, p_map_1.default)(updatesWithLocalLinks, (node) => {
492
- var _a, _b;
476
+ return pMap(updatesWithLocalLinks, (node) => {
493
477
  for (const [depName, resolved] of node.localDependencies) {
494
478
  // regardless of where the version comes from, we can't publish 'file:../sibling-pkg' specs
495
- const depVersion = ((_a = this.updatesVersions) === null || _a === void 0 ? void 0 : _a.get(depName)) || ((_b = this.packageGraph) === null || _b === void 0 ? void 0 : _b.get(depName).pkg.version);
479
+ const depVersion = this.updatesVersions?.get(depName) || this.packageGraph?.get(depName).pkg.version;
496
480
  // it no longer matters if we mutate the shared Package instance
497
- node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.options.workspaceStrictMatch, this.commandName);
481
+ node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.commandName);
498
482
  }
499
483
  // writing changes to disk handled in serializeChanges()
500
484
  });
@@ -502,15 +486,14 @@ class PublishCommand extends core_1.Command {
502
486
  resolveLocalDependencyWorkspaceProtocols() {
503
487
  // resolve workspace protocol: translates to their actual version target/range
504
488
  const publishingPackagesWithLocalWorkspaces = this.updates.filter((node) => Array.from(node.localDependencies.values()).some((resolved) => resolved.workspaceSpec));
505
- return (0, p_map_1.default)(publishingPackagesWithLocalWorkspaces, (node) => {
489
+ return pMap(publishingPackagesWithLocalWorkspaces, (node) => {
506
490
  // regardless of where the version comes from, we can't publish 'workspace:*' specs, it has to be transformed for both local & external dependencies
507
491
  // e.g. considering version is `1.2.3` and we have `workspace:*` it will be converted to "^1.2.3" or to "1.2.3" with strict match range enabled
508
- var _a, _b;
509
492
  // 1. update & bump version of local dependencies
510
493
  for (const [depName, resolved] of node.localDependencies) {
511
- const depVersion = ((_a = this.updatesVersions) === null || _a === void 0 ? void 0 : _a.get(depName)) || ((_b = this.packageGraph) === null || _b === void 0 ? void 0 : _b.get(depName).pkg.version);
494
+ const depVersion = this.updatesVersions?.get(depName) || this.packageGraph?.get(depName).pkg.version;
512
495
  // it no longer matters if we mutate the shared Package instance
513
- node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.options.workspaceStrictMatch, this.commandName);
496
+ node.pkg.updateLocalDependency(resolved, depVersion, this.savePrefix, this.options.allowPeerDependenciesUpdate, this.commandName);
514
497
  }
515
498
  // 2. remove any "workspace:" prefix from the package to be published any of external dependencies (without anything being bumped)
516
499
  // we will only accept "workspace:" with semver version, for example "workspace:1.2.3" is ok but "workspace:*" will log an error
@@ -521,10 +504,9 @@ class PublishCommand extends core_1.Command {
521
504
  });
522
505
  }
523
506
  annotateGitHead() {
524
- var _a;
525
507
  try {
526
- const gitHead = this.options.gitHead || (0, get_current_sha_1.getCurrentSHA)(this.execOpts);
527
- for (const pkg of (_a = this.packagesToPublish) !== null && _a !== void 0 ? _a : []) {
508
+ const gitHead = this.options.gitHead || getCurrentSHA(this.execOpts);
509
+ for (const pkg of this.packagesToPublish ?? []) {
528
510
  // provide gitHead property that is normally added during npm publish
529
511
  pkg.set('gitHead', gitHead);
530
512
  }
@@ -537,8 +519,7 @@ class PublishCommand extends core_1.Command {
537
519
  // writing changes to disk handled in serializeChanges()
538
520
  }
539
521
  serializeChanges() {
540
- var _a;
541
- return (0, p_map_1.default)((_a = this.packagesToPublish) !== null && _a !== void 0 ? _a : [], (pkg) => pkg.serialize());
522
+ return pMap(this.packagesToPublish ?? [], (pkg) => pkg.serialize());
542
523
  }
543
524
  resetChanges() {
544
525
  // the package.json files are changed (by gitHead if not --canary)
@@ -547,43 +528,30 @@ class PublishCommand extends core_1.Command {
547
528
  const gitOpts = {
548
529
  granularPathspec: this.options.granularPathspec !== false,
549
530
  };
531
+ // prettier-ignore
550
532
  const dirtyManifests = [this.project.manifest]
551
533
  .concat(this.packagesToPublish)
552
- .map((pkg) => path_1.default.relative(cwd, pkg.manifestLocation));
553
- return (0, git_checkout_1.gitCheckout)(dirtyManifests, gitOpts, this.execOpts, this.options.dryRun).catch((err) => {
534
+ .map((pkg) => relative(cwd, pkg.manifestLocation));
535
+ return gitCheckout(dirtyManifests, gitOpts, this.execOpts, this.options.dryRun).catch((err) => {
554
536
  this.logger.silly('EGITCHECKOUT', err.message);
555
537
  this.logger.notice('FYI', `Unable to reset working tree changes, this probably isn't a git repo.`);
556
538
  });
557
539
  }
558
- // @deprecated, see Lerna PR https://github.com/lerna/lerna/pull/1862/files
559
- execScript(pkg, script) {
560
- const scriptLocation = path_1.default.join(pkg.location, 'scripts', script);
561
- try {
562
- require(scriptLocation);
563
- }
564
- catch (ex) {
565
- this.logger.silly('execScript', `No ${script} script found at ${scriptLocation}`);
566
- }
567
- return pkg;
568
- }
569
540
  removePackageProperties() {
570
541
  const { removePackageFields } = this.options;
571
- return (0, p_map_1.default)(this.updates, (node) => {
542
+ return pMap(this.updates, (node) => {
572
543
  if (Array.isArray(removePackageFields)) {
573
544
  for (const removeField of removePackageFields) {
574
- (0, core_1.deleteComplexObjectProp)(node.pkg.manifest, removeField, `"${node.pkg.name}" package`);
545
+ deleteComplexObjectProp(node.pkg.manifest, removeField, `"${node.pkg.name}" package`);
575
546
  }
576
547
  }
577
548
  });
578
549
  }
579
550
  removeTempLicensesOnError(error) {
580
551
  return Promise.resolve()
581
- .then(() => {
582
- var _a;
583
- return (0, remove_temp_licenses_1.removeTempLicenses)((_a = this.packagesToBeLicensed) !== null && _a !== void 0 ? _a : []).catch((removeError) => {
584
- this.logger.error('licenses', 'error removing temporary license files', removeError.stack || removeError);
585
- });
586
- })
552
+ .then(() => removeTempLicenses(this.packagesToBeLicensed ?? []).catch((removeError) => {
553
+ this.logger.error('licenses', 'error removing temporary license files', removeError.stack || removeError);
554
+ }))
587
555
  .then(() => {
588
556
  // restore original error into promise chain
589
557
  throw error;
@@ -591,7 +559,7 @@ class PublishCommand extends core_1.Command {
591
559
  }
592
560
  requestOneTimePassword() {
593
561
  if (this.options.dryRun) {
594
- this.logger.info(chalk_1.default.bold.magenta('[dry-run] >'), 'will ask OTP');
562
+ this.logger.info(chalk.bold.magenta('[dry-run] >'), 'will ask OTP');
595
563
  return;
596
564
  }
597
565
  // if OTP has already been provided, skip prompt
@@ -599,11 +567,11 @@ class PublishCommand extends core_1.Command {
599
567
  return;
600
568
  }
601
569
  return Promise.resolve()
602
- .then(() => (0, version_1.getOneTimePassword)('Enter OTP:'))
570
+ .then(() => getOneTimePassword('Enter OTP:'))
603
571
  .then((otp) => (this.otpCache.otp = otp));
604
572
  }
605
573
  topoMapPackages(mapper) {
606
- return (0, core_1.runTopologically)(this.packagesToPublish, mapper, {
574
+ return runTopologically(this.packagesToPublish, mapper, {
607
575
  concurrency: this.concurrency,
608
576
  rejectCycles: this.options.rejectCycles,
609
577
  /**
@@ -626,11 +594,10 @@ class PublishCommand extends core_1.Command {
626
594
  });
627
595
  }
628
596
  packUpdated() {
629
- var _a;
630
597
  const tracker = this.logger.newItem('npm pack');
631
- tracker.addWork((_a = this.packagesToPublish) === null || _a === void 0 ? void 0 : _a.length);
598
+ tracker.addWork(this.packagesToPublish?.length);
632
599
  let chain = Promise.resolve();
633
- chain = chain.then(() => { var _a; return (0, create_temp_licenses_1.createTempLicenses)(this.project.licensePath, (_a = this.packagesToBeLicensed) !== null && _a !== void 0 ? _a : []); });
600
+ chain = chain.then(() => createTempLicenses(this.project.licensePath, this.packagesToBeLicensed ?? []));
634
601
  if (!this.hasRootedLeaf) {
635
602
  // despite being deprecated for years...
636
603
  chain = chain.then(() => this.runRootLifecycle('prepublish'));
@@ -640,11 +607,9 @@ class PublishCommand extends core_1.Command {
640
607
  chain = chain.then(() => this.runPackageLifecycle(this.project.manifest, 'prepack'));
641
608
  }
642
609
  const opts = this.conf.snapshot;
643
- const mapper = (0, p_pipe_1.default)(...[
644
- this.options.requireScripts && ((pkg) => this.execScript(pkg, 'prepublish')),
645
- (pkg) => (0, core_1.pulseTillDone)((0, pack_directory_1.packDirectory)(pkg, pkg.location, opts)).then((packed) => {
646
- var _a;
647
- tracker.verbose('packed', path_1.default.relative((_a = this.project.rootPath) !== null && _a !== void 0 ? _a : '', pkg.contents));
610
+ const mapper = pPipe(...[
611
+ (pkg) => pulseTillDone(packDirectory(pkg, pkg.location, opts)).then((packed) => {
612
+ tracker.verbose('packed', relative(this.project.rootPath ?? '', pkg.contents));
648
613
  tracker.completeWork(1);
649
614
  // store metadata for use in this.publishPacked()
650
615
  pkg.packed = packed;
@@ -656,9 +621,9 @@ class PublishCommand extends core_1.Command {
656
621
  if (this.toposort) {
657
622
  return this.topoMapPackages(mapper);
658
623
  }
659
- return (0, p_map_1.default)(this.packagesToPublish, mapper, { concurrency: this.concurrency });
624
+ return pMap(this.packagesToPublish, mapper, { concurrency: this.concurrency });
660
625
  });
661
- chain = chain.then(() => { var _a; return (0, remove_temp_licenses_1.removeTempLicenses)((_a = this.packagesToBeLicensed) !== null && _a !== void 0 ? _a : []); });
626
+ chain = chain.then(() => removeTempLicenses(this.packagesToBeLicensed ?? []));
662
627
  // remove temporary license files if _any_ error occurs _anywhere_ in the promise chain
663
628
  chain = chain.catch((error) => this.removeTempLicensesOnError(error));
664
629
  if (!this.hasRootedLeaf) {
@@ -667,10 +632,9 @@ class PublishCommand extends core_1.Command {
667
632
  return chain.finally(() => tracker.finish());
668
633
  }
669
634
  publishPacked() {
670
- var _a;
671
635
  this.publishedPackages = [];
672
636
  const tracker = this.logger.newItem('publish');
673
- tracker.addWork((_a = this.packagesToPublish) === null || _a === void 0 ? void 0 : _a.length);
637
+ tracker.addWork(this.packagesToPublish?.length);
674
638
  let chain = Promise.resolve();
675
639
  // if account-level 2FA is enabled, prime the OTP cache
676
640
  if (this.twoFactorAuthRequired) {
@@ -682,17 +646,17 @@ class PublishCommand extends core_1.Command {
682
646
  tag: this.options.tempTag ? 'lerna-temp' : this.conf.get('tag'),
683
647
  'git-dry-run': this.options.dryRun || false,
684
648
  });
685
- const mapper = (0, p_pipe_1.default)(...[
649
+ const mapper = pPipe(...[
686
650
  (pkg) => {
687
651
  const preDistTag = this.getPreDistTag(pkg);
688
652
  const tag = !this.options.tempTag && preDistTag ? preDistTag : opts.tag;
689
653
  const pkgOpts = Object.assign({}, opts, { tag });
690
- return (0, core_1.pulseTillDone)((0, npm_publish_1.npmPublish)(pkg, pkg.packed.tarFilePath, pkgOpts, this.otpCache))
654
+ return pulseTillDone(npmPublish(pkg, pkg.packed.tarFilePath, pkgOpts, this.otpCache))
691
655
  .then(() => {
692
656
  this.publishedPackages.push(pkg);
693
657
  tracker.success('published', pkg.name, pkg.version);
694
658
  tracker.completeWork(1);
695
- (0, log_packed_1.logPacked)(pkg, this.options.dryRun);
659
+ logPacked(pkg, this.options.dryRun);
696
660
  return pkg;
697
661
  })
698
662
  .catch((err) => {
@@ -710,13 +674,12 @@ class PublishCommand extends core_1.Command {
710
674
  throw err;
711
675
  });
712
676
  },
713
- this.options.requireScripts && ((pkg) => this.execScript(pkg, 'postpublish')),
714
677
  ].filter(Boolean));
715
678
  chain = chain.then(() => {
716
679
  if (this.toposort) {
717
680
  return this.topoMapPackages(mapper);
718
681
  }
719
- return (0, p_map_1.default)(this.packagesToPublish, mapper, { concurrency: this.concurrency });
682
+ return pMap(this.packagesToPublish, mapper, { concurrency: this.concurrency });
720
683
  });
721
684
  if (!this.hasRootedLeaf) {
722
685
  // cyclical 'publish' lifecycles are automatically skipped
@@ -726,14 +689,13 @@ class PublishCommand extends core_1.Command {
726
689
  return chain.finally(() => tracker.finish());
727
690
  }
728
691
  npmUpdateAsLatest() {
729
- var _a;
730
692
  const tracker = this.logger.newItem('npmUpdateAsLatest');
731
- tracker.addWork((_a = this.packagesToPublish) === null || _a === void 0 ? void 0 : _a.length);
693
+ tracker.addWork(this.packagesToPublish?.length);
732
694
  tracker.showProgress();
733
695
  let chain = Promise.resolve();
734
696
  const opts = this.conf.snapshot;
735
697
  const getDistTag = (publishConfig) => {
736
- if (opts.tag === 'latest' && (publishConfig === null || publishConfig === void 0 ? void 0 : publishConfig.tag)) {
698
+ if (opts.tag === 'latest' && publishConfig?.tag) {
737
699
  return publishConfig.tag;
738
700
  }
739
701
  return opts.tag;
@@ -743,8 +705,8 @@ class PublishCommand extends core_1.Command {
743
705
  const preDistTag = this.getPreDistTag(pkg);
744
706
  const distTag = preDistTag || getDistTag(pkg.get('publishConfig'));
745
707
  return Promise.resolve()
746
- .then(() => (0, core_1.pulseTillDone)((0, npm_dist_tag_1.remove)(spec, 'lerna-temp', opts, this.otpCache)))
747
- .then(() => (0, core_1.pulseTillDone)((0, npm_dist_tag_1.add)(spec, distTag, opts, this.otpCache)))
708
+ .then(() => pulseTillDone(remove(spec, 'lerna-temp', opts, this.otpCache)))
709
+ .then(() => pulseTillDone(add(spec, distTag, opts, this.otpCache)))
748
710
  .then(() => {
749
711
  tracker.success('dist-tag', '%s@%s => %j', pkg.name, pkg.version, distTag);
750
712
  tracker.completeWork(1);
@@ -755,7 +717,7 @@ class PublishCommand extends core_1.Command {
755
717
  if (this.toposort) {
756
718
  return this.topoMapPackages(mapper);
757
719
  }
758
- return (0, p_map_1.default)(this.packagesToPublish, mapper, { concurrency: this.concurrency });
720
+ return pMap(this.packagesToPublish, mapper, { concurrency: this.concurrency });
759
721
  });
760
722
  return chain.finally(() => tracker.finish());
761
723
  }
@@ -772,11 +734,10 @@ class PublishCommand extends core_1.Command {
772
734
  if (!this.options.preDistTag) {
773
735
  return;
774
736
  }
775
- const isPrerelease = (0, core_1.prereleaseIdFromVersion)(pkg.version);
737
+ const isPrerelease = prereleaseIdFromVersion(pkg.version);
776
738
  if (isPrerelease) {
777
739
  return this.options.preDistTag;
778
740
  }
779
741
  }
780
742
  }
781
- exports.PublishCommand = PublishCommand;
782
743
  //# sourceMappingURL=publish-command.js.map