@lerna-lite/publish 1.1.0 → 1.4.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.
Files changed (63) hide show
  1. package/README.md +474 -417
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.js +19 -18
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/create-temp-licenses.d.ts +7 -7
  6. package/dist/lib/create-temp-licenses.js +32 -32
  7. package/dist/lib/create-temp-licenses.js.map +1 -1
  8. package/dist/lib/fetch-config.d.ts +10 -7
  9. package/dist/lib/fetch-config.js +21 -21
  10. package/dist/lib/fetch-config.js.map +1 -1
  11. package/dist/lib/get-current-sha.d.ts +6 -6
  12. package/dist/lib/get-current-sha.js +19 -19
  13. package/dist/lib/get-current-tags.d.ts +8 -8
  14. package/dist/lib/get-current-tags.js +35 -35
  15. package/dist/lib/get-npm-username.d.ts +7 -7
  16. package/dist/lib/get-npm-username.js +49 -49
  17. package/dist/lib/get-npm-username.js.map +1 -1
  18. package/dist/lib/get-packages-without-license.d.ts +8 -8
  19. package/dist/lib/get-packages-without-license.js +23 -23
  20. package/dist/lib/get-packages-without-license.js.map +1 -1
  21. package/dist/lib/get-packed.d.ts +2 -2
  22. package/dist/lib/get-packed.js +65 -65
  23. package/dist/lib/get-profile-data.d.ts +7 -7
  24. package/dist/lib/get-profile-data.js +22 -22
  25. package/dist/lib/get-tagged-packages.d.ts +9 -8
  26. package/dist/lib/get-tagged-packages.js +29 -29
  27. package/dist/lib/get-tagged-packages.js.map +1 -1
  28. package/dist/lib/get-two-factor-auth-required.d.ts +7 -7
  29. package/dist/lib/get-two-factor-auth-required.js +42 -42
  30. package/dist/lib/get-two-factor-auth-required.js.map +1 -1
  31. package/dist/lib/get-unpublished-packages.d.ts +8 -8
  32. package/dist/lib/get-unpublished-packages.js +36 -36
  33. package/dist/lib/get-whoami.d.ts +11 -11
  34. package/dist/lib/get-whoami.js +20 -20
  35. package/dist/lib/git-checkout.d.ts +10 -7
  36. package/dist/lib/git-checkout.js +20 -20
  37. package/dist/lib/git-checkout.js.map +1 -1
  38. package/dist/lib/index.d.ts +19 -19
  39. package/dist/lib/index.js +35 -35
  40. package/dist/lib/log-packed.d.ts +2 -1
  41. package/dist/lib/log-packed.js +67 -67
  42. package/dist/lib/log-packed.js.map +1 -1
  43. package/dist/lib/npm-dist-tag.d.ts +33 -30
  44. package/dist/lib/npm-dist-tag.js +139 -141
  45. package/dist/lib/npm-dist-tag.js.map +1 -1
  46. package/dist/lib/npm-publish.d.ts +10 -11
  47. package/dist/lib/npm-publish.js +102 -116
  48. package/dist/lib/npm-publish.js.map +1 -1
  49. package/dist/lib/pack-directory.d.ts +8 -8
  50. package/dist/lib/pack-directory.js +66 -67
  51. package/dist/lib/pack-directory.js.map +1 -1
  52. package/dist/lib/remove-temp-licenses.d.ts +6 -6
  53. package/dist/lib/remove-temp-licenses.js +19 -19
  54. package/dist/lib/verify-npm-package-access.d.ts +9 -9
  55. package/dist/lib/verify-npm-package-access.js +55 -55
  56. package/dist/lib/verify-npm-package-access.js.map +1 -1
  57. package/dist/models/index.d.ts +32 -0
  58. package/dist/models/index.js +3 -0
  59. package/dist/models/index.js.map +1 -0
  60. package/dist/publish-command.d.ts +64 -61
  61. package/dist/publish-command.js +642 -626
  62. package/dist/publish-command.js.map +1 -1
  63. package/package.json +9 -10
@@ -1,66 +1,66 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPacked = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const ssri_1 = __importDefault(require("ssri"));
10
- const tar_1 = __importDefault(require("tar"));
11
- function getPacked(pkg, tarFilePath) {
12
- const bundledWanted = new Set(/* pkg.bundleDependencies || pkg.bundledDependencies || */ []);
13
- const bundled = new Set();
14
- const files = [];
15
- let totalEntries = 0;
16
- let totalEntrySize = 0;
17
- return tar_1.default
18
- .list({
19
- file: tarFilePath,
20
- onentry(entry) {
21
- totalEntries += 1;
22
- totalEntrySize += entry.size;
23
- const p = entry.path;
24
- /* istanbul ignore if */
25
- if (p.startsWith('package/node_modules/')) {
26
- const name = p.match(/^package\/node_modules\/((?:@[^/]+\/)?[^/]+)/)[1];
27
- if (bundledWanted.has(name)) {
28
- bundled.add(name);
29
- }
30
- }
31
- else {
32
- files.push({
33
- path: entry.path.replace(/^package\//, ''),
34
- size: entry.size,
35
- mode: entry.mode,
36
- });
37
- }
38
- },
39
- strip: 1,
40
- })
41
- .then(() => Promise.all([
42
- fs_extra_1.default.stat(tarFilePath),
43
- ssri_1.default.fromStream(fs_extra_1.default.createReadStream(tarFilePath), {
44
- algorithms: ['sha1', 'sha512'],
45
- }),
46
- ]))
47
- .then(([{ size }, { sha1, sha512 }]) => {
48
- const shasum = sha1[0].hexDigest();
49
- return {
50
- id: `${pkg.name}@${pkg.version}`,
51
- name: pkg.name,
52
- version: pkg.version,
53
- size,
54
- unpackedSize: totalEntrySize,
55
- shasum,
56
- integrity: ssri_1.default.parse(sha512[0]),
57
- filename: path_1.default.basename(tarFilePath),
58
- files,
59
- entryCount: totalEntries,
60
- bundled: Array.from(bundled),
61
- tarFilePath,
62
- };
63
- });
64
- }
65
- exports.getPacked = getPacked;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPacked = void 0;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const ssri_1 = __importDefault(require("ssri"));
10
+ const tar_1 = __importDefault(require("tar"));
11
+ function getPacked(pkg, tarFilePath) {
12
+ const bundledWanted = new Set(/* pkg.bundleDependencies || pkg.bundledDependencies || */ []);
13
+ const bundled = new Set();
14
+ const files = [];
15
+ let totalEntries = 0;
16
+ let totalEntrySize = 0;
17
+ return tar_1.default
18
+ .list({
19
+ file: tarFilePath,
20
+ onentry(entry) {
21
+ totalEntries += 1;
22
+ totalEntrySize += entry.size;
23
+ const p = entry.path;
24
+ /* istanbul ignore if */
25
+ if (p.startsWith('package/node_modules/')) {
26
+ const name = p.match(/^package\/node_modules\/((?:@[^/]+\/)?[^/]+)/)[1];
27
+ if (bundledWanted.has(name)) {
28
+ bundled.add(name);
29
+ }
30
+ }
31
+ else {
32
+ files.push({
33
+ path: entry.path.replace(/^package\//, ''),
34
+ size: entry.size,
35
+ mode: entry.mode,
36
+ });
37
+ }
38
+ },
39
+ strip: 1,
40
+ })
41
+ .then(() => Promise.all([
42
+ fs_extra_1.default.stat(tarFilePath),
43
+ ssri_1.default.fromStream(fs_extra_1.default.createReadStream(tarFilePath), {
44
+ algorithms: ['sha1', 'sha512'],
45
+ }),
46
+ ]))
47
+ .then(([{ size }, { sha1, sha512 }]) => {
48
+ const shasum = sha1[0].hexDigest();
49
+ return {
50
+ id: `${pkg.name}@${pkg.version}`,
51
+ name: pkg.name,
52
+ version: pkg.version,
53
+ size,
54
+ unpackedSize: totalEntrySize,
55
+ shasum,
56
+ integrity: ssri_1.default.parse(sha512[0]),
57
+ filename: path_1.default.basename(tarFilePath),
58
+ files,
59
+ entryCount: totalEntries,
60
+ bundled: Array.from(bundled),
61
+ tarFilePath,
62
+ };
63
+ });
64
+ }
65
+ exports.getPacked = getPacked;
66
66
  //# sourceMappingURL=get-packed.js.map
@@ -1,7 +1,7 @@
1
- import { FetchConfig, ProfileData } from '@lerna-lite/core';
2
- /**
3
- * Retrieve profile data of logged-in user.
4
- * @param {import("./fetch-config").FetchConfig} opts
5
- * @returns {Promise<ProfileData>}
6
- */
7
- export declare function getProfileData(opts: FetchConfig): Promise<ProfileData>;
1
+ import { FetchConfig, ProfileData } from '@lerna-lite/core';
2
+ /**
3
+ * Retrieve profile data of logged-in user.
4
+ * @param {import("./fetch-config").FetchConfig} opts
5
+ * @returns {Promise<ProfileData>}
6
+ */
7
+ export declare function getProfileData(opts: FetchConfig): Promise<ProfileData>;
@@ -1,23 +1,23 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getProfileData = void 0;
7
- const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
8
- const core_1 = require("@lerna-lite/core");
9
- /**
10
- * Retrieve profile data of logged-in user.
11
- * @param {import("./fetch-config").FetchConfig} opts
12
- * @returns {Promise<ProfileData>}
13
- */
14
- async function getProfileData(opts) {
15
- opts.log.verbose('', 'Retrieving npm user profile');
16
- const data = await (0, core_1.pulseTillDone)(await npm_registry_fetch_1.default.json('/-/npm/v1/user', opts));
17
- opts.log.silly('npm profile get', 'received %j', data);
18
- return Object.assign(
19
- // remap to match legacy whoami format
20
- { username: data.name }, data);
21
- }
22
- exports.getProfileData = getProfileData;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getProfileData = void 0;
7
+ const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
8
+ const core_1 = require("@lerna-lite/core");
9
+ /**
10
+ * Retrieve profile data of logged-in user.
11
+ * @param {import("./fetch-config").FetchConfig} opts
12
+ * @returns {Promise<ProfileData>}
13
+ */
14
+ async function getProfileData(opts) {
15
+ opts.log.verbose('', 'Retrieving npm user profile');
16
+ const data = await (0, core_1.pulseTillDone)(await npm_registry_fetch_1.default.json('/-/npm/v1/user', opts));
17
+ opts.log.silly('npm profile get', 'received %j', data);
18
+ return Object.assign(
19
+ // remap to match legacy whoami format
20
+ { username: data.name }, data);
21
+ }
22
+ exports.getProfileData = getProfileData;
23
23
  //# sourceMappingURL=get-profile-data.js.map
@@ -1,8 +1,9 @@
1
- /**
2
- * Retrieve a list of graph nodes for packages that were tagged in a non-independent release.
3
- * @param {import("@lerna/package-graph").PackageGraph} packageGraph
4
- * @param {string} rootPath
5
- * @param {import("@lerna/child-process").ExecOpts} execOpts
6
- * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
7
- */
8
- export declare function getTaggedPackages(packageGraph: any, rootPath: any, execOpts: any, gitDryRun?: boolean): Promise<unknown[]>;
1
+ import { ExecOpts, PackageGraph } from '@lerna-lite/core';
2
+ /**
3
+ * Retrieve a list of graph nodes for packages that were tagged in a non-independent release.
4
+ * @param {import("@lerna/package-graph").PackageGraph} packageGraph
5
+ * @param {string} rootPath
6
+ * @param {import("@lerna/child-process").ExecOpts} execOpts
7
+ * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
8
+ */
9
+ export declare function getTaggedPackages(packageGraph: PackageGraph, rootPath: string, execOpts: ExecOpts, gitDryRun?: boolean): Promise<any[]>;
@@ -1,30 +1,30 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getTaggedPackages = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const npmlog_1 = __importDefault(require("npmlog"));
9
- const core_1 = require("@lerna-lite/core");
10
- /**
11
- * Retrieve a list of graph nodes for packages that were tagged in a non-independent release.
12
- * @param {import("@lerna/package-graph").PackageGraph} packageGraph
13
- * @param {string} rootPath
14
- * @param {import("@lerna/child-process").ExecOpts} execOpts
15
- * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
16
- */
17
- function getTaggedPackages(packageGraph, rootPath, execOpts, gitDryRun = false) {
18
- npmlog_1.default.silly('getTaggedPackages', '');
19
- // @see https://stackoverflow.com/a/424142/5707
20
- // FIXME: --root is only necessary for tests :P
21
- return (0, core_1.exec)('git', ['diff-tree', '--name-only', '--no-commit-id', '--root', '-r', '-c', 'HEAD'], execOpts, gitDryRun)
22
- .then(({ stdout }) => {
23
- const manifests = stdout.split('\n').filter((fp) => path_1.default.basename(fp) === 'package.json');
24
- const locations = new Set(manifests.map((fp) => path_1.default.join(rootPath, path_1.default.dirname(fp))));
25
- // @ts-ignore
26
- return Array.from(packageGraph.values()).filter((node) => locations.has(node.location));
27
- });
28
- }
29
- exports.getTaggedPackages = getTaggedPackages;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getTaggedPackages = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const npmlog_1 = __importDefault(require("npmlog"));
9
+ const core_1 = require("@lerna-lite/core");
10
+ /**
11
+ * Retrieve a list of graph nodes for packages that were tagged in a non-independent release.
12
+ * @param {import("@lerna/package-graph").PackageGraph} packageGraph
13
+ * @param {string} rootPath
14
+ * @param {import("@lerna/child-process").ExecOpts} execOpts
15
+ * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
16
+ */
17
+ function getTaggedPackages(packageGraph, rootPath, execOpts, gitDryRun = false) {
18
+ npmlog_1.default.silly('getTaggedPackages', '');
19
+ // @see https://stackoverflow.com/a/424142/5707
20
+ // FIXME: --root is only necessary for tests :P
21
+ return (0, core_1.exec)('git', ['diff-tree', '--name-only', '--no-commit-id', '--root', '-r', '-c', 'HEAD'], execOpts, gitDryRun)
22
+ .then(({ stdout }) => {
23
+ const manifests = stdout.split('\n').filter((fp) => path_1.default.basename(fp) === 'package.json');
24
+ const locations = new Set(manifests.map((fp) => path_1.default.join(rootPath, path_1.default.dirname(fp))));
25
+ // @ts-ignore
26
+ return Array.from(packageGraph.values()).filter((node) => locations.has(node.location));
27
+ });
28
+ }
29
+ exports.getTaggedPackages = getTaggedPackages;
30
30
  //# sourceMappingURL=get-tagged-packages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-tagged-packages.js","sourceRoot":"","sources":["../../src/lib/get-tagged-packages.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAyB;AACzB,2CAAwC;AAExC;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,GAAG,KAAK;IACnF,gBAAG,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAEnC,+CAA+C;IAC/C,+CAA+C;IAC/C,OAAO,IAAA,WAAI,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC;SAClH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACnB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,cAAc,CAAC,CAAC;QAC1F,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhG,aAAa;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChH,CAAC,CAAC,CAAC;AACP,CAAC;AAbD,8CAaC"}
1
+ {"version":3,"file":"get-tagged-packages.js","sourceRoot":"","sources":["../../src/lib/get-tagged-packages.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAAyB;AACzB,2CAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,YAA0B,EAAE,QAAgB,EAAE,QAAkB,EAAE,SAAS,GAAG,KAAK;IACnH,gBAAG,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;IAEnC,+CAA+C;IAC/C,+CAA+C;IAC/C,OAAO,IAAA,WAAI,EAAC,KAAK,EAAE,CAAC,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC;SAClH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;QACnB,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,cAAc,CAAC,CAAC;QAC1F,MAAM,SAAS,GAAG,IAAI,GAAG,CAAS,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhG,aAAa;QACb,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAA0B,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChH,CAAC,CAAC,CAAC;AACP,CAAC;AAbD,8CAaC"}
@@ -1,7 +1,7 @@
1
- import { FetchConfig } from '@lerna-lite/core';
2
- /**
3
- * Determine if the logged-in user has enabled two-factor auth.
4
- * @param {import('./fetch-config').FetchConfig} options
5
- * @returns {Promise<boolean>}
6
- */
7
- export declare function getTwoFactorAuthRequired(options: FetchConfig): Promise<boolean>;
1
+ import { FetchConfig } from '@lerna-lite/core';
2
+ /**
3
+ * Determine if the logged-in user has enabled two-factor auth.
4
+ * @param {import('./fetch-config').FetchConfig} options
5
+ * @returns {Promise<boolean>}
6
+ */
7
+ export declare function getTwoFactorAuthRequired(options: FetchConfig): Promise<boolean>;
@@ -1,43 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTwoFactorAuthRequired = void 0;
4
- const core_1 = require("@lerna-lite/core");
5
- const fetch_config_1 = require("./fetch-config");
6
- const get_profile_data_1 = require("./get-profile-data");
7
- /**
8
- * Determine if the logged-in user has enabled two-factor auth.
9
- * @param {import('./fetch-config').FetchConfig} options
10
- * @returns {Promise<boolean>}
11
- */
12
- function getTwoFactorAuthRequired(options) {
13
- const opts = (0, fetch_config_1.getFetchConfig)(options, {
14
- // don't wait forever for third-party failures to be dealt with
15
- fetchRetries: 0,
16
- });
17
- opts.log.info('', 'Checking two-factor auth mode');
18
- return (0, get_profile_data_1.getProfileData)(opts).then(success, failure);
19
- function success(result) {
20
- opts.log.silly('2FA', result.tfa);
21
- if (result.tfa.pending) {
22
- // if 2FA is pending, it is disabled
23
- return false;
24
- }
25
- return result.tfa.mode === 'auth-and-writes';
26
- }
27
- function failure(err) {
28
- // pass if registry does not support profile endpoint
29
- if (err.code === 'E500' || err.code === 'E404') {
30
- // most likely a private registry (npm Enterprise, verdaccio, etc)
31
- opts.log.warn('EREGISTRY', `Registry "${opts.registry}" does not support 'npm profile get', skipping two-factor auth check...`);
32
- // don't log redundant errors
33
- return false;
34
- }
35
- // Log the error cleanly to stderr
36
- opts.log.pause();
37
- console.error(err.message); // eslint-disable-line no-console
38
- opts.log.resume();
39
- throw new core_1.ValidationError('ETWOFACTOR', 'Unable to obtain two-factor auth mode');
40
- }
41
- }
42
- exports.getTwoFactorAuthRequired = getTwoFactorAuthRequired;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTwoFactorAuthRequired = void 0;
4
+ const core_1 = require("@lerna-lite/core");
5
+ const fetch_config_1 = require("./fetch-config");
6
+ const get_profile_data_1 = require("./get-profile-data");
7
+ /**
8
+ * Determine if the logged-in user has enabled two-factor auth.
9
+ * @param {import('./fetch-config').FetchConfig} options
10
+ * @returns {Promise<boolean>}
11
+ */
12
+ function getTwoFactorAuthRequired(options) {
13
+ const opts = (0, fetch_config_1.getFetchConfig)(options, {
14
+ // don't wait forever for third-party failures to be dealt with
15
+ fetchRetries: 0,
16
+ });
17
+ opts.log.info('', 'Checking two-factor auth mode');
18
+ return (0, get_profile_data_1.getProfileData)(opts).then(success, failure);
19
+ function success(result) {
20
+ opts.log.silly('2FA', result.tfa.toString());
21
+ if (result.tfa.pending) {
22
+ // if 2FA is pending, it is disabled
23
+ return false;
24
+ }
25
+ return result.tfa.mode === 'auth-and-writes';
26
+ }
27
+ function failure(err) {
28
+ // pass if registry does not support profile endpoint
29
+ if (err.code === 'E500' || err.code === 'E404') {
30
+ // most likely a private registry (npm Enterprise, verdaccio, etc)
31
+ opts.log.warn('EREGISTRY', `Registry "${opts.registry}" does not support 'npm profile get', skipping two-factor auth check...`);
32
+ // don't log redundant errors
33
+ return false;
34
+ }
35
+ // Log the error cleanly to stderr
36
+ opts.log.pause();
37
+ console.error(err.message); // eslint-disable-line no-console
38
+ opts.log.resume();
39
+ throw new core_1.ValidationError('ETWOFACTOR', 'Unable to obtain two-factor auth mode');
40
+ }
41
+ }
42
+ exports.getTwoFactorAuthRequired = getTwoFactorAuthRequired;
43
43
  //# sourceMappingURL=get-two-factor-auth-required.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-two-factor-auth-required.js","sourceRoot":"","sources":["../../src/lib/get-two-factor-auth-required.ts"],"names":[],"mappings":";;;AAAA,2CAAgE;AAEhE,iDAAgD;AAChD,yDAAoD;AAEpD;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,OAAoB;IAC3D,MAAM,IAAI,GAAG,IAAA,6BAAc,EAAC,OAAO,EAAE;QACnC,+DAA+D;QAC/D,YAAY,EAAE,CAAC;KAChB,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,+BAA+B,CAAC,CAAC;IAEnD,OAAO,IAAA,iCAAc,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEnD,SAAS,OAAO,CAAC,MAAM;QACrB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE;YACtB,oCAAoC;YACpC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC;IAC/C,CAAC;IAED,SAAS,OAAO,CAAC,GAAG;QAClB,qDAAqD;QACrD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;YAC9C,kEAAkE;YAClE,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,WAAW,EACX,aAAa,IAAI,CAAC,QAAQ,yEAAyE,CACpG,CAAC;YAEF,6BAA6B;YAC7B,OAAO,KAAK,CAAC;SACd;QAED,kCAAkC;QAClC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC;QAC7D,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAElB,MAAM,IAAI,sBAAe,CAAC,YAAY,EAAE,uCAAuC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAzCD,4DAyCC"}
1
+ {"version":3,"file":"get-two-factor-auth-required.js","sourceRoot":"","sources":["../../src/lib/get-two-factor-auth-required.ts"],"names":[],"mappings":";;;AAAA,2CAAgE;AAEhE,iDAAgD;AAChD,yDAAoD;AAEpD;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,OAAoB;IAC3D,MAAM,IAAI,GAAG,IAAA,6BAAc,EAAC,OAAO,EAAE;QACnC,+DAA+D;QAC/D,YAAY,EAAE,CAAC;KAChB,CAAC,CAAC;IAEH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,+BAA+B,CAAC,CAAC;IAEnD,OAAO,IAAA,iCAAc,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEnD,SAAS,OAAO,CAAC,MAAoD;QACnE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QAE7C,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE;YACtB,oCAAoC;YACpC,OAAO,KAAK,CAAC;SACd;QAED,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC;IAC/C,CAAC;IAED,SAAS,OAAO,CAAC,GAAQ;QACvB,qDAAqD;QACrD,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,EAAE;YAC9C,kEAAkE;YAClE,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,WAAW,EACX,aAAa,IAAI,CAAC,QAAQ,yEAAyE,CACpG,CAAC;YAEF,6BAA6B;YAC7B,OAAO,KAAK,CAAC;SACd;QAED,kCAAkC;QAClC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACjB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC;QAC7D,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAElB,MAAM,IAAI,sBAAe,CAAC,YAAY,EAAE,uCAAuC,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAzCD,4DAyCC"}
@@ -1,8 +1,8 @@
1
- import { FetchConfig, PackageGraph, PackageGraphNode } from '@lerna-lite/core';
2
- /**
3
- * Retrieve a list of graph nodes for packages that need to be published.
4
- * @param {import("@lerna/package-graph").PackageGraph} packageGraph
5
- * @param {import("./fetch-config").FetchConfig} opts
6
- * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
7
- */
8
- export declare function getUnpublishedPackages(packageGraph: PackageGraph, opts: FetchConfig): Promise<PackageGraphNode>;
1
+ import { FetchConfig, PackageGraph, PackageGraphNode } from '@lerna-lite/core';
2
+ /**
3
+ * Retrieve a list of graph nodes for packages that need to be published.
4
+ * @param {import("@lerna/package-graph").PackageGraph} packageGraph
5
+ * @param {import("./fetch-config").FetchConfig} opts
6
+ * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
7
+ */
8
+ export declare function getUnpublishedPackages(packageGraph: PackageGraph, opts: FetchConfig): Promise<PackageGraphNode>;
@@ -1,37 +1,37 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getUnpublishedPackages = void 0;
7
- const npmlog_1 = __importDefault(require("npmlog"));
8
- const p_map_1 = __importDefault(require("p-map"));
9
- const pacote_1 = __importDefault(require("pacote"));
10
- /**
11
- * Retrieve a list of graph nodes for packages that need to be published.
12
- * @param {import("@lerna/package-graph").PackageGraph} packageGraph
13
- * @param {import("./fetch-config").FetchConfig} opts
14
- * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
15
- */
16
- function getUnpublishedPackages(packageGraph, opts) {
17
- npmlog_1.default.silly('getUnpublishedPackages', '');
18
- let chain = Promise.resolve();
19
- // don't bother attempting to get the packument for private packages
20
- // @ts-ignore
21
- const graphNodesToCheck = Array.from(packageGraph.values()).filter(({ pkg }) => !pkg.private);
22
- const mapper = (pkg) => {
23
- var _a;
24
- return pacote_1.default.packument((_a = pkg === null || pkg === void 0 ? void 0 : pkg.name) !== null && _a !== void 0 ? _a : '', opts).then((packument) => {
25
- if (packument.versions === undefined || packument.versions[pkg.version] === undefined) {
26
- return pkg;
27
- }
28
- }, () => {
29
- npmlog_1.default.warn('', 'Unable to determine published version, assuming %j unpublished.', pkg.name);
30
- return pkg;
31
- });
32
- };
33
- chain = chain.then(() => (0, p_map_1.default)(graphNodesToCheck, mapper, { concurrency: 4 }));
34
- return chain.then((results) => results.filter(Boolean));
35
- }
36
- exports.getUnpublishedPackages = getUnpublishedPackages;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getUnpublishedPackages = void 0;
7
+ const npmlog_1 = __importDefault(require("npmlog"));
8
+ const p_map_1 = __importDefault(require("p-map"));
9
+ const pacote_1 = __importDefault(require("pacote"));
10
+ /**
11
+ * Retrieve a list of graph nodes for packages that need to be published.
12
+ * @param {import("@lerna/package-graph").PackageGraph} packageGraph
13
+ * @param {import("./fetch-config").FetchConfig} opts
14
+ * @returns {Promise<import("@lerna/package-graph").PackageGraphNode[]>}
15
+ */
16
+ function getUnpublishedPackages(packageGraph, opts) {
17
+ npmlog_1.default.silly('getUnpublishedPackages', '');
18
+ let chain = Promise.resolve();
19
+ // don't bother attempting to get the packument for private packages
20
+ // @ts-ignore
21
+ const graphNodesToCheck = Array.from(packageGraph.values()).filter(({ pkg }) => !pkg.private);
22
+ const mapper = (pkg) => {
23
+ var _a;
24
+ return pacote_1.default.packument((_a = pkg === null || pkg === void 0 ? void 0 : pkg.name) !== null && _a !== void 0 ? _a : '', opts).then((packument) => {
25
+ if (packument.versions === undefined || packument.versions[pkg.version] === undefined) {
26
+ return pkg;
27
+ }
28
+ }, () => {
29
+ npmlog_1.default.warn('', 'Unable to determine published version, assuming %j unpublished.', pkg.name);
30
+ return pkg;
31
+ });
32
+ };
33
+ chain = chain.then(() => (0, p_map_1.default)(graphNodesToCheck, mapper, { concurrency: 4 }));
34
+ return chain.then((results) => results.filter(Boolean));
35
+ }
36
+ exports.getUnpublishedPackages = getUnpublishedPackages;
37
37
  //# sourceMappingURL=get-unpublished-packages.js.map
@@ -1,11 +1,11 @@
1
- import { FetchConfig } from '@lerna-lite/core';
2
- interface WhoIAm {
3
- username: string;
4
- }
5
- /**
6
- * Retrieve logged-in user's username via legacy API.
7
- * @param {import("./fetch-config").FetchConfig} opts
8
- * @returns {WhoIAm}
9
- */
10
- export declare function getWhoAmI(opts: FetchConfig): Promise<WhoIAm>;
11
- export {};
1
+ import { FetchConfig } from '@lerna-lite/core';
2
+ interface WhoIAm {
3
+ username: string;
4
+ }
5
+ /**
6
+ * Retrieve logged-in user's username via legacy API.
7
+ * @param {import("./fetch-config").FetchConfig} opts
8
+ * @returns {WhoIAm}
9
+ */
10
+ export declare function getWhoAmI(opts: FetchConfig): Promise<WhoIAm>;
11
+ export {};
@@ -1,21 +1,21 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getWhoAmI = void 0;
7
- const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
8
- const core_1 = require("@lerna-lite/core");
9
- /**
10
- * Retrieve logged-in user's username via legacy API.
11
- * @param {import("./fetch-config").FetchConfig} opts
12
- * @returns {WhoIAm}
13
- */
14
- async function getWhoAmI(opts) {
15
- opts.log.verbose('', 'Retrieving npm username');
16
- const data = (0, core_1.pulseTillDone)(await npm_registry_fetch_1.default.json('/-/whoami', opts));
17
- opts.log.silly('npm whoami', 'received %j', data);
18
- return data;
19
- }
20
- exports.getWhoAmI = getWhoAmI;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getWhoAmI = void 0;
7
+ const npm_registry_fetch_1 = __importDefault(require("npm-registry-fetch"));
8
+ const core_1 = require("@lerna-lite/core");
9
+ /**
10
+ * Retrieve logged-in user's username via legacy API.
11
+ * @param {import("./fetch-config").FetchConfig} opts
12
+ * @returns {WhoIAm}
13
+ */
14
+ async function getWhoAmI(opts) {
15
+ opts.log.verbose('', 'Retrieving npm username');
16
+ const data = (0, core_1.pulseTillDone)(await npm_registry_fetch_1.default.json('/-/whoami', opts));
17
+ opts.log.silly('npm whoami', 'received %j', data);
18
+ return data;
19
+ }
20
+ exports.getWhoAmI = getWhoAmI;
21
21
  //# sourceMappingURL=get-whoami.js.map
@@ -1,7 +1,10 @@
1
- /**
2
- * Reset files modified by publish steps.
3
- * @param {string[]} stagedFiles
4
- * @param {{ granularPathspec: boolean; }} gitOpts
5
- * @param {import("@lerna/child-process").ExecOpts} execOpts
6
- */
7
- export declare function gitCheckout(stagedFiles: any, gitOpts: any, execOpts: any, gitDryRun?: boolean): Promise<any>;
1
+ import { ExecOpts } from '@lerna-lite/core';
2
+ /**
3
+ * Reset files modified by publish steps.
4
+ * @param {string[]} stagedFiles
5
+ * @param {{ granularPathspec: boolean; }} gitOpts
6
+ * @param {import("@lerna/child-process").ExecOpts} execOpts
7
+ */
8
+ export declare function gitCheckout(stagedFiles: string[], gitOpts: {
9
+ granularPathspec: boolean;
10
+ }, execOpts: ExecOpts, gitDryRun?: boolean): Promise<any>;
@@ -1,21 +1,21 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.gitCheckout = void 0;
7
- const npmlog_1 = __importDefault(require("npmlog"));
8
- const core_1 = require("@lerna-lite/core");
9
- /**
10
- * Reset files modified by publish steps.
11
- * @param {string[]} stagedFiles
12
- * @param {{ granularPathspec: boolean; }} gitOpts
13
- * @param {import("@lerna/child-process").ExecOpts} execOpts
14
- */
15
- function gitCheckout(stagedFiles, gitOpts, execOpts, gitDryRun = false) {
16
- const files = gitOpts.granularPathspec ? stagedFiles : '.';
17
- npmlog_1.default.silly('gitCheckout', files);
18
- return (0, core_1.exec)('git', ['checkout', '--'].concat(files), execOpts, gitDryRun);
19
- }
20
- exports.gitCheckout = gitCheckout;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.gitCheckout = void 0;
7
+ const npmlog_1 = __importDefault(require("npmlog"));
8
+ const core_1 = require("@lerna-lite/core");
9
+ /**
10
+ * Reset files modified by publish steps.
11
+ * @param {string[]} stagedFiles
12
+ * @param {{ granularPathspec: boolean; }} gitOpts
13
+ * @param {import("@lerna/child-process").ExecOpts} execOpts
14
+ */
15
+ function gitCheckout(stagedFiles, gitOpts, execOpts, gitDryRun = false) {
16
+ const files = (gitOpts.granularPathspec ? stagedFiles : '.');
17
+ npmlog_1.default.silly('gitCheckout', files);
18
+ return (0, core_1.exec)('git', ['checkout', '--'].concat(files), execOpts, gitDryRun);
19
+ }
20
+ exports.gitCheckout = gitCheckout;
21
21
  //# sourceMappingURL=git-checkout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"git-checkout.js","sourceRoot":"","sources":["../../src/lib/git-checkout.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAyB;AAEzB,2CAAwC;AAExC;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,GAAG,KAAK;IAC3E,MAAM,KAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC;IAE3D,gBAAG,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAEhC,OAAO,IAAA,WAAI,EAAC,KAAK,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC;AAND,kCAMC"}
1
+ {"version":3,"file":"git-checkout.js","sourceRoot":"","sources":["../../src/lib/git-checkout.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAyB;AAEzB,2CAAkD;AAElD;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,WAAqB,EAAE,OAAuC,EAAE,QAAkB,EAAE,SAAS,GAAG,KAAK;IAC/H,MAAM,KAAK,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAW,CAAC;IAEvE,gBAAG,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAEhC,OAAO,IAAA,WAAI,EAAC,KAAK,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC5E,CAAC;AAND,kCAMC"}