release-it 14.11.8 → 15.0.0-esm.3

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 (53) hide show
  1. package/bin/release-it.js +6 -4
  2. package/lib/cli.js +18 -4
  3. package/lib/config.js +12 -14
  4. package/lib/deprecated.js +6 -4
  5. package/lib/index.js +139 -13
  6. package/lib/log.js +6 -4
  7. package/lib/metrics.js +11 -8
  8. package/lib/plugin/GitBase.js +4 -4
  9. package/lib/plugin/GitRelease.js +6 -4
  10. package/lib/plugin/Plugin.js +3 -3
  11. package/lib/plugin/factory.js +26 -14
  12. package/lib/plugin/git/Git.js +7 -7
  13. package/lib/plugin/git/prompts.js +2 -2
  14. package/lib/plugin/github/GitHub.js +20 -15
  15. package/lib/plugin/github/prompts.js +2 -2
  16. package/lib/plugin/gitlab/GitLab.js +10 -10
  17. package/lib/plugin/gitlab/prompts.js +2 -2
  18. package/lib/plugin/npm/npm.js +8 -8
  19. package/lib/plugin/npm/prompts.js +1 -1
  20. package/lib/plugin/version/Version.js +4 -4
  21. package/lib/prompt.js +2 -2
  22. package/lib/shell.js +7 -5
  23. package/lib/spinner.js +5 -5
  24. package/lib/util.js +13 -9
  25. package/package.json +19 -17
  26. package/test/cli.js +6 -4
  27. package/test/config.js +7 -5
  28. package/test/deprecated.js +4 -4
  29. package/test/git.init.js +9 -7
  30. package/test/git.js +7 -7
  31. package/test/github.js +57 -15
  32. package/test/gitlab.js +7 -7
  33. package/test/log.js +5 -5
  34. package/test/metrics.js +3 -3
  35. package/test/npm.js +7 -9
  36. package/test/plugins.js +92 -117
  37. package/test/prompt.js +9 -9
  38. package/test/shell.js +6 -6
  39. package/test/spinner.js +11 -13
  40. package/test/stub/github.js +2 -2
  41. package/test/stub/gitlab.js +7 -9
  42. package/test/stub/plugin-context.js +36 -0
  43. package/test/stub/plugin-replace.js +9 -0
  44. package/test/stub/plugin.js +39 -0
  45. package/test/stub/shell.js +5 -3
  46. package/test/tasks.interactive.js +14 -14
  47. package/test/tasks.js +35 -34
  48. package/test/util/helpers.js +5 -10
  49. package/test/util/index.js +12 -12
  50. package/test/util/setup.js +2 -14
  51. package/test/utils.js +5 -5
  52. package/test/version.js +4 -4
  53. package/lib/tasks.js +0 -139
package/bin/release-it.js CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const updater = require('update-notifier');
4
- const parseArgs = require('yargs-parser');
5
- const pkg = require('../package.json');
6
- const release = require('../lib');
3
+ import updater from 'update-notifier';
4
+ import parseArgs from 'yargs-parser';
5
+ import release from '../lib/cli.js';
6
+ import { readJSON } from '../lib/util.js';
7
+
8
+ const pkg = readJSON(new URL('../package.json', import.meta.url));
7
9
 
8
10
  const aliases = {
9
11
  c: 'config',
package/lib/cli.js CHANGED
@@ -1,5 +1,8 @@
1
- const pkg = require('../package.json');
2
- const Log = require('./log');
1
+ import { readJSON } from './util.js';
2
+ import Log from './log.js';
3
+ import runTasks from './index.js';
4
+
5
+ const pkg = readJSON(new URL('../package.json', import.meta.url));
3
6
 
4
7
  const log = new Log();
5
8
 
@@ -22,6 +25,17 @@ const helpText = `Release It! v${pkg.version}
22
25
 
23
26
  For more details, please see https://github.com/release-it/release-it`;
24
27
 
25
- module.exports.version = () => log.log(`v${pkg.version}`);
28
+ export let version = () => log.log(`v${pkg.version}`);
29
+
30
+ export let help = () => log.log(helpText);
26
31
 
27
- module.exports.help = () => log.log(helpText);
32
+ export default async options => {
33
+ if (options.version) {
34
+ version();
35
+ } else if (options.help) {
36
+ help();
37
+ } else {
38
+ return runTasks(options);
39
+ }
40
+ return Promise.resolve();
41
+ };
package/lib/config.js CHANGED
@@ -1,12 +1,14 @@
1
- const { cosmiconfigSync } = require('cosmiconfig');
2
- const parseJson = require('parse-json');
3
- const parseToml = require('@iarna/toml/parse-string');
4
- const yaml = require('yaml');
5
- const _ = require('lodash');
6
- const isCI = require('is-ci');
7
- const debug = require('debug')('release-it:config');
8
- const defaultConfig = require('../config/release-it.json');
9
- const { getSystemInfo } = require('./util');
1
+ import { cosmiconfigSync } from 'cosmiconfig';
2
+ import parseJson from 'parse-json';
3
+ import parseToml from '@iarna/toml/parse-string.js';
4
+ import yaml from 'yaml';
5
+ import _ from 'lodash';
6
+ import isCI from 'is-ci';
7
+ import _debug from 'debug';
8
+ import { readJSON, getSystemInfo } from './util.js';
9
+
10
+ const debug = _debug('release-it:config');
11
+ const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
10
12
 
11
13
  const searchPlaces = [
12
14
  'package.json',
@@ -52,10 +54,6 @@ class Config {
52
54
 
53
55
  expandPreReleaseShorthand(options) {
54
56
  const { increment, preRelease, preReleaseId } = options;
55
- if (options.github.release && increment === false) {
56
- console.warn('Using --no-increment with --github.release is deprecated. Add --github.update in release-it v15.');
57
- options.github.update = increment === false;
58
- }
59
57
  options.version = {
60
58
  increment,
61
59
  isPreRelease: Boolean(preRelease),
@@ -131,4 +129,4 @@ class Config {
131
129
  }
132
130
  }
133
131
 
134
- module.exports = Config;
132
+ export default Config;
package/lib/deprecated.js CHANGED
@@ -1,8 +1,10 @@
1
- const Deprecated = require('deprecated-obj');
2
- const deprecated = require('../config/deprecated.json');
3
- const Log = require('./log');
1
+ import Deprecated from 'deprecated-obj';
2
+ import { readJSON } from './util.js';
3
+ import Log from './log.js';
4
4
 
5
- module.exports = (config, log = new Log()) => {
5
+ const deprecated = readJSON(new URL('../config/deprecated.json', import.meta.url));
6
+
7
+ export default (config, log = new Log()) => {
6
8
  const deprecations = new Deprecated(deprecated, config);
7
9
  const compliant = deprecations.getCompliant();
8
10
  const violations = deprecations.getViolations();
package/lib/index.js CHANGED
@@ -1,16 +1,142 @@
1
- const { version, help } = require('./cli');
2
- const runTasks = require('./tasks');
3
- const Plugin = require('./plugin/Plugin');
4
-
5
- module.exports = async options => {
6
- if (options.version) {
7
- version();
8
- } else if (options.help) {
9
- help();
10
- } else {
11
- return runTasks(options);
1
+ import _ from 'lodash';
2
+ import { getPlugins } from './plugin/factory.js';
3
+ import Logger from './log.js';
4
+ import Config from './config.js';
5
+ import Shell from './shell.js';
6
+ import Prompt from './prompt.js';
7
+ import Spinner from './spinner.js';
8
+ import Metrics from './metrics.js';
9
+ import { reduceUntil, parseVersion } from './util.js';
10
+ import handleDeprecated from './deprecated.js';
11
+ import Plugin from './plugin/Plugin.js';
12
+
13
+ const runTasks = async (opts, di) => {
14
+ let container = {};
15
+
16
+ try {
17
+ Object.assign(container, di);
18
+ container.config = container.config || new Config(opts);
19
+
20
+ const { config } = container;
21
+ const { isCI, isVerbose, verbosityLevel, isDryRun } = config;
22
+
23
+ container.log = container.log || new Logger({ isCI, isVerbose, verbosityLevel, isDryRun });
24
+ container.spinner = container.spinner || new Spinner({ container, config });
25
+ container.prompt = container.prompt || new Prompt({ container: { config } });
26
+ container.metrics = new Metrics({ isEnabled: config.isCollectMetrics });
27
+ container.shell = container.shell || new Shell({ container });
28
+
29
+ const { log, metrics, shell, spinner } = container;
30
+
31
+ const options = handleDeprecated(config.getContext(), log);
32
+
33
+ metrics.trackEvent('start', options);
34
+
35
+ const { hooks } = options;
36
+
37
+ const runHook = async (...name) => {
38
+ const scripts = hooks[name.join(':')];
39
+ if (!scripts || !scripts.length) return;
40
+ const context = config.getContext();
41
+ const external = true;
42
+ for (const script of _.castArray(scripts)) {
43
+ const task = () => shell.exec(script, { external }, context);
44
+ await spinner.show({ task, label: script, context, external });
45
+ }
46
+ };
47
+
48
+ const runLifeCycleHook = async (plugin, name, ...args) => {
49
+ if (plugin === _.first(plugins)) await runHook('before', name);
50
+ await runHook('before', plugin.namespace, name);
51
+ const willHookRun = (await plugin[name](...args)) !== false;
52
+ if (willHookRun) {
53
+ await runHook('after', plugin.namespace, name);
54
+ }
55
+ if (plugin === _.last(plugins)) await runHook('after', name);
56
+ };
57
+
58
+ const [internal, external] = await getPlugins(config, container);
59
+ let plugins = [...external, ...internal];
60
+
61
+ for (const plugin of plugins) {
62
+ await runLifeCycleHook(plugin, 'init');
63
+ }
64
+
65
+ const { increment, isPreRelease, preReleaseId } = options.version;
66
+
67
+ const name = await reduceUntil(plugins, plugin => plugin.getName());
68
+ const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
69
+ const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion));
70
+
71
+ const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId };
72
+
73
+ let version;
74
+ if (config.isIncrement) {
75
+ incrementBase.increment = await reduceUntil(plugins, plugin => plugin.getIncrement(incrementBase));
76
+ version = await reduceUntil(plugins, plugin => plugin.getIncrementedVersionCI(incrementBase));
77
+ } else {
78
+ version = latestVersion;
79
+ }
80
+
81
+ if (config.isReleaseVersion) {
82
+ log.log(version);
83
+ process.exit(0);
84
+ }
85
+
86
+ config.setContext({ name, latestVersion, version, changelog });
87
+
88
+ const action = config.isIncrement ? 'release' : 'update';
89
+ const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`;
90
+
91
+ log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`);
92
+
93
+ log.preview({ title: 'changelog', text: changelog });
94
+
95
+ if (config.isIncrement) {
96
+ version = version || (await reduceUntil(plugins, plugin => plugin.getIncrementedVersion(incrementBase)));
97
+ }
98
+
99
+ config.setContext(parseVersion(version));
100
+
101
+ if (config.isPromptOnlyVersion) {
102
+ config.setCI(true);
103
+ }
104
+
105
+ for (const hook of ['beforeBump', 'bump', 'beforeRelease']) {
106
+ for (const plugin of plugins) {
107
+ const args = hook === 'bump' ? [version] : [];
108
+ await runLifeCycleHook(plugin, hook, ...args);
109
+ }
110
+ }
111
+
112
+ plugins = [...internal, ...external];
113
+
114
+ for (const hook of ['release', 'afterRelease']) {
115
+ for (const plugin of plugins) {
116
+ await runLifeCycleHook(plugin, hook);
117
+ }
118
+ }
119
+
120
+ await metrics.trackEvent('end');
121
+
122
+ log.log(`🏁 Done (in ${Math.floor(process.uptime())}s.)`);
123
+
124
+ return {
125
+ name,
126
+ changelog,
127
+ latestVersion,
128
+ version
129
+ };
130
+ } catch (err) {
131
+ const { log, metrics } = container;
132
+ if (metrics) {
133
+ await metrics.trackException(err);
134
+ }
135
+ log ? log.error(err.message || err) : console.error(err); // eslint-disable-line no-console
136
+ throw err;
12
137
  }
13
- return Promise.resolve();
14
138
  };
15
139
 
16
- module.exports.Plugin = Plugin;
140
+ export default runTasks;
141
+
142
+ export { Plugin };
package/lib/log.js CHANGED
@@ -1,6 +1,8 @@
1
- const { EOL } = require('os');
2
- const chalk = require('chalk');
3
- const { isObject, last, filter, isString, lowerCase, upperFirst, isArray } = require('lodash');
1
+ import { EOL } from 'os';
2
+ import chalk from 'chalk';
3
+ import _ from 'lodash';
4
+
5
+ const { isObject, last, filter, isString, lowerCase, upperFirst, isArray } = _;
4
6
 
5
7
  class Logger {
6
8
  constructor({ isCI = true, isVerbose = false, verbosityLevel = 0, isDryRun = false } = {}) {
@@ -64,4 +66,4 @@ class Logger {
64
66
  }
65
67
  }
66
68
 
67
- module.exports = Logger;
69
+ export default Logger;
package/lib/metrics.js CHANGED
@@ -1,10 +1,13 @@
1
- const { EOL } = require('os');
2
- const got = require('got');
3
- const { v4: uuidv4 } = require('uuid');
4
- const osName = require('os-name');
5
- const isCi = require('is-ci');
6
- const debug = require('debug')('release-it:metrics');
7
- const pkg = require('../package.json');
1
+ import { EOL } from 'os';
2
+ import got from 'got';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import osName from 'os-name';
5
+ import isCi from 'is-ci';
6
+ import _debug from 'debug';
7
+ import { readJSON } from './util.js';
8
+
9
+ const debug = _debug('release-it:metrics');
10
+ const pkg = readJSON(new URL('../package.json', import.meta.url));
8
11
 
9
12
  const noop = Promise.resolve();
10
13
 
@@ -70,4 +73,4 @@ class Metrics {
70
73
  }
71
74
  }
72
75
 
73
- module.exports = Metrics;
76
+ export default Metrics;
@@ -1,6 +1,6 @@
1
- const { EOL } = require('os');
2
- const { format, parseGitUrl } = require('../util');
3
- const Plugin = require('./Plugin');
1
+ import { EOL } from 'os';
2
+ import { format, parseGitUrl } from '../util.js';
3
+ import Plugin from './Plugin.js';
4
4
 
5
5
  const options = { write: false };
6
6
  const changelogFallback = 'git log --pretty=format:"* %s (%h)"';
@@ -103,4 +103,4 @@ class GitBase extends Plugin {
103
103
  }
104
104
  }
105
105
 
106
- module.exports = GitBase;
106
+ export default GitBase;
@@ -1,6 +1,8 @@
1
- const _ = require('lodash');
2
- const defaultConfig = require('../../config/release-it.json');
3
- const GitBase = require('./GitBase');
1
+ import _ from 'lodash';
2
+ import { readJSON } from '../util.js';
3
+ import GitBase from './GitBase.js';
4
+
5
+ const defaultConfig = readJSON(new URL('../../config/release-it.json', import.meta.url));
4
6
 
5
7
  class GitRelease extends GitBase {
6
8
  static isEnabled(options) {
@@ -37,4 +39,4 @@ class GitRelease extends GitBase {
37
39
  }
38
40
  }
39
41
 
40
- module.exports = GitRelease;
42
+ export default GitRelease;
@@ -1,5 +1,5 @@
1
- const debug = require('debug');
2
- const _ = require('lodash');
1
+ import debug from 'debug';
2
+ import _ from 'lodash';
3
3
 
4
4
  class Plugin {
5
5
  static isEnabled() {
@@ -69,4 +69,4 @@ class Plugin {
69
69
  }
70
70
  }
71
71
 
72
- module.exports = Plugin;
72
+ export default Plugin;
@@ -1,12 +1,15 @@
1
- const path = require('path');
2
- const _ = require('lodash');
3
- const requireCwd = require('import-cwd');
4
- const debug = require('debug')('release-it:plugins');
5
- const Version = require('./version/Version');
6
- const Git = require('./git/Git');
7
- const GitLab = require('./gitlab/GitLab');
8
- const GitHub = require('./github/GitHub');
9
- const npm = require('./npm/npm');
1
+ import url from 'url';
2
+ import path from 'path';
3
+ import { createRequire } from 'module';
4
+ import _ from 'lodash';
5
+ import _debug from 'debug';
6
+ import Version from './version/Version.js';
7
+ import Git from './git/Git.js';
8
+ import GitLab from './gitlab/GitLab.js';
9
+ import GitHub from './github/GitHub.js';
10
+ import npm from './npm/npm.js';
11
+
12
+ const debug = _debug('release-it:plugins');
10
13
 
11
14
  const pluginNames = ['npm', 'git', 'github', 'gitlab', 'version'];
12
15
 
@@ -18,24 +21,33 @@ const plugins = {
18
21
  npm: npm
19
22
  };
20
23
 
21
- const load = pluginName => {
24
+ const load = async pluginName => {
22
25
  let plugin = null;
23
26
  try {
24
- plugin = require(pluginName);
27
+ const module = await import(pluginName);
28
+ plugin = module.default;
25
29
  } catch (err) {
26
- plugin = requireCwd(pluginName);
30
+ try {
31
+ const module = await import(path.join(process.cwd(), pluginName));
32
+ plugin = module.default;
33
+ } catch (err) {
34
+ // In some cases or tests we might need to support legacy `require.resolve`
35
+ const require = createRequire(process.cwd());
36
+ const module = await import(url.pathToFileURL(require.resolve(pluginName, { paths: [process.cwd()] })));
37
+ plugin = module.default;
38
+ }
27
39
  }
28
40
  return [path.parse(pluginName).name, plugin];
29
41
  };
30
42
 
31
- module.exports.getPlugins = async (config, container) => {
43
+ export let getPlugins = async (config, container) => {
32
44
  const context = config.getContext();
33
45
  const disabledPlugins = [];
34
46
 
35
47
  const enabledExternalPlugins = await _.reduce(
36
48
  context.plugins,
37
49
  async (result, pluginConfig, pluginName) => {
38
- const [name, Plugin] = load(pluginName);
50
+ const [name, Plugin] = await load(pluginName);
39
51
  const [namespace, options] = pluginConfig.length === 2 ? pluginConfig : [name, pluginConfig];
40
52
  config.setContext({ [namespace]: options });
41
53
  if (await Plugin.isEnabled(options)) {
@@ -1,9 +1,9 @@
1
- const { EOL } = require('os');
2
- const _ = require('lodash');
3
- const execa = require('execa');
4
- const { format, e } = require('../../util');
5
- const GitBase = require('../GitBase');
6
- const prompts = require('./prompts');
1
+ import { EOL } from 'os';
2
+ import _ from 'lodash';
3
+ import { execa } from 'execa';
4
+ import { format, e } from '../../util.js';
5
+ import GitBase from '../GitBase.js';
6
+ import prompts from './prompts.js';
7
7
 
8
8
  const noop = Promise.resolve();
9
9
  const invalidPushRepoRe = /^\S+@/;
@@ -208,4 +208,4 @@ class Git extends GitBase {
208
208
  }
209
209
  }
210
210
 
211
- module.exports = Git;
211
+ export default Git;
@@ -1,6 +1,6 @@
1
- const { format, truncateLines } = require('../../util');
1
+ import { format, truncateLines } from '../../util.js';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  commit: {
5
5
  type: 'confirm',
6
6
  message: context => `Commit (${truncateLines(format(context.git.commitMessage, context), 1, ' [...]')})?`,
@@ -1,16 +1,17 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { Octokit } = require('@octokit/rest');
4
- const globby = require('globby');
5
- const mime = require('mime-types');
6
- const _ = require('lodash');
7
- const retry = require('async-retry');
8
- const newGithubReleaseUrl = require('new-github-release-url');
9
- const open = require('open');
10
- const pkg = require('../../../package.json');
11
- const { format, parseVersion, e } = require('../../util');
12
- const Release = require('../GitRelease');
13
- const prompts = require('./prompts');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import open from 'open';
4
+ import { Octokit } from '@octokit/rest';
5
+ import { globby } from 'globby';
6
+ import mime from 'mime-types';
7
+ import _ from 'lodash';
8
+ import retry from 'async-retry';
9
+ import newGithubReleaseUrl from 'new-github-release-url';
10
+ import { format, parseVersion, readJSON, e } from '../../util.js';
11
+ import Release from '../GitRelease.js';
12
+ import prompts from './prompts.js';
13
+
14
+ const pkg = readJSON(new URL('../../../package.json', import.meta.url));
14
15
 
15
16
  const docs = 'https://git.io/release-it-github';
16
17
 
@@ -295,8 +296,11 @@ class GitHub extends Release {
295
296
  }
296
297
 
297
298
  generateWebUrl() {
299
+ const host = this.options.host || this.getContext('repo.host');
300
+ const isGitHub = host === 'github.com';
301
+
298
302
  const options = this.getOctokitReleaseOptions();
299
- return newGithubReleaseUrl({
303
+ const url = newGithubReleaseUrl({
300
304
  user: options.owner,
301
305
  repo: options.repo,
302
306
  tag: options.tag_name,
@@ -304,6 +308,7 @@ class GitHub extends Release {
304
308
  title: options.name,
305
309
  body: options.body
306
310
  });
311
+ return isGitHub ? url : url.replace('github.com', host);
307
312
  }
308
313
 
309
314
  async createWebRelease() {
@@ -342,4 +347,4 @@ class GitHub extends Release {
342
347
  }
343
348
  }
344
349
 
345
- module.exports = GitHub;
350
+ export default GitHub;
@@ -1,4 +1,4 @@
1
- const { format } = require('../../util');
1
+ import { format } from '../../util.js';
2
2
 
3
3
  const message = context => {
4
4
  const { isPreRelease, github } = context;
@@ -7,7 +7,7 @@ const message = context => {
7
7
  return `${update ? 'Update' : 'Create a'} ${isPreRelease ? 'pre-' : ''}release on GitHub (${name})?`;
8
8
  };
9
9
 
10
- module.exports = {
10
+ export default {
11
11
  release: {
12
12
  type: 'confirm',
13
13
  message,
@@ -1,12 +1,12 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const got = require('got');
4
- const globby = require('globby');
5
- const FormData = require('form-data');
6
- const _ = require('lodash');
7
- const Release = require('../GitRelease');
8
- const { format, e } = require('../../util');
9
- const prompts = require('./prompts');
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import got from 'got';
4
+ import { globby } from 'globby';
5
+ import FormData from 'form-data';
6
+ import _ from 'lodash';
7
+ import Release from '../GitRelease.js';
8
+ import { format, e } from '../../util.js';
9
+ import prompts from './prompts.js';
10
10
 
11
11
  const docs = 'https://git.io/release-it-gitlab';
12
12
 
@@ -216,4 +216,4 @@ class GitLab extends Release {
216
216
  }
217
217
  }
218
218
 
219
- module.exports = GitLab;
219
+ export default GitLab;
@@ -1,6 +1,6 @@
1
- const { format } = require('../../util');
1
+ import { format } from '../../util.js';
2
2
 
3
- module.exports = {
3
+ export default {
4
4
  release: {
5
5
  type: 'confirm',
6
6
  message: context => `Create a release on GitLab (${format(context.gitlab.releaseName, context)})?`,
@@ -1,9 +1,9 @@
1
- const path = require('path');
2
- const semver = require('semver');
3
- const urlJoin = require('url-join');
4
- const Plugin = require('../Plugin');
5
- const { hasAccess, rejectAfter, parseVersion, e } = require('../../util');
6
- const prompts = require('./prompts');
1
+ import path from 'path';
2
+ import semver from 'semver';
3
+ import urlJoin from 'url-join';
4
+ import Plugin from '../Plugin.js';
5
+ import { hasAccess, rejectAfter, parseVersion, readJSON, e } from '../../util.js';
6
+ import prompts from './prompts.js';
7
7
 
8
8
  const docs = 'https://git.io/release-it-npm';
9
9
 
@@ -27,7 +27,7 @@ class npm extends Plugin {
27
27
  }
28
28
 
29
29
  async init() {
30
- const { name, version: latestVersion, private: isPrivate, publishConfig } = require(path.resolve(MANIFEST_PATH));
30
+ const { name, version: latestVersion, private: isPrivate, publishConfig } = readJSON(path.resolve(MANIFEST_PATH));
31
31
  this.setContext({ name, latestVersion, private: isPrivate, publishConfig });
32
32
 
33
33
  const { publish, skipChecks } = this.options;
@@ -255,4 +255,4 @@ class npm extends Plugin {
255
255
  }
256
256
  }
257
257
 
258
- module.exports = npm;
258
+ export default npm;
@@ -1,4 +1,4 @@
1
- module.exports = {
1
+ export default {
2
2
  publish: {
3
3
  type: 'confirm',
4
4
  message: context =>
@@ -1,6 +1,6 @@
1
- const semver = require('semver');
2
- const chalk = require('chalk');
3
- const Plugin = require('../Plugin');
1
+ import semver from 'semver';
2
+ import chalk from 'chalk';
3
+ import Plugin from '../Plugin.js';
4
4
 
5
5
  const { green, red, redBright } = chalk;
6
6
 
@@ -122,4 +122,4 @@ class Version extends Plugin {
122
122
  }
123
123
  }
124
124
 
125
- module.exports = Version;
125
+ export default Version;
package/lib/prompt.js CHANGED
@@ -1,4 +1,4 @@
1
- const inquirer = require('inquirer');
1
+ import inquirer from 'inquirer';
2
2
 
3
3
  class Prompt {
4
4
  constructor({ container }) {
@@ -30,4 +30,4 @@ class Prompt {
30
30
  }
31
31
  }
32
32
 
33
- module.exports = Prompt;
33
+ export default Prompt;