Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to using ESM #158

Merged
merged 4 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module.exports = {
extends: ['eslint:recommended', 'plugin:node/recommended', 'prettier'],
plugins: ['prettier', 'node'],
parserOptions: {
ecmaVersion: 2017,
sourceType: 'script',
ecmaVersion: 2020,
sourceType: 'module',
},
env: {
node: true,
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ on:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 14.x
- run: npm ci
- run: npm run lint:js

build:
name: "Node ${{ matrix.node-version }}"

Expand All @@ -23,7 +34,6 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: install dependencies
run: npm ci
- run: npm run lint:js
- run: npm test

release-it-compat:
Expand All @@ -43,5 +53,4 @@ jobs:
- name: install dependencies
run: npm ci
- run: npm install --saveDev release-it@${{ matrix.release-it-version }}
- run: npm run lint:js
- run: npm test
36 changes: 21 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
'use strict';

const { EOL } = require('os');
const fs = require('fs');
const which = require('which');
const { Plugin } = require('release-it');
const { format } = require('release-it/lib/util');
const tmp = require('tmp');
const execa = require('execa');
const parse = require('mdast-util-from-markdown');

require('validate-peer-dependencies')(__dirname);

import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
import { createRequire } from 'node:module';
import { EOL } from 'node:os';
import fs from 'node:fs';
import which from 'which';
import { Plugin } from 'release-it';
import { format } from 'release-it/lib/util.js';
import tmp from 'tmp';
import execa from 'execa';
import parse from 'mdast-util-from-markdown';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

import validatePeerDependencies from 'validate-peer-dependencies';
validatePeerDependencies(__dirname);

const require = createRequire(import.meta.url);
const LERNA_PATH = require.resolve('lerna-changelog/bin/cli');

// using a const here, because we may need to change this value in the future
Expand All @@ -23,7 +29,7 @@ function getToday() {
return date.slice(0, date.indexOf('T'));
}

module.exports = class LernaChangelogGeneratorPlugin extends Plugin {
export default class LernaChangelogGeneratorPlugin extends Plugin {
async init() {
let from = (await this.getTagForHEAD()) || (await this.getFirstCommit());
this.changelog = await this._execLernaChangelog(from);
Expand Down Expand Up @@ -202,4 +208,4 @@ module.exports = class LernaChangelogGeneratorPlugin extends Plugin {
await this.writeChangelog(processedChangelog);
}
}
};
}
74 changes: 27 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"ava": {
"serial": true
},
"type": "module",
"dependencies": {
"execa": "^4.1.0",
"lerna-changelog": "^2.2.0",
Expand All @@ -35,18 +36,18 @@
"devDependencies": {
"ava": "^3.15.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.2.1",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"release-it": "^14.10.1",
"sinon": "^9.2.4"
},
"peerDependencies": {
"release-it": "^14.0.0"
},
"engines": {
"node": "12.* || 14.* || >= 16"
"node": "^12.20.0 || ^14.13.1 || >= 16"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
16 changes: 9 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
'use strict';
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import tmp from 'tmp';
import test from 'ava';
import { factory, runTasks } from 'release-it/test/util/index.js';
import Plugin from './index.js';

const fs = require('fs');
const path = require('path');
const tmp = require('tmp');
const test = require('ava');
const { factory, runTasks } = require('release-it/test/util');
const Plugin = require('./index');
const EDITOR = process.env.EDITOR || null;
const PATH = process.env.PATH;

tmp.setGracefulCleanup();

const require = createRequire(import.meta.url);

const LERNA_PATH = require.resolve('lerna-changelog/bin/cli');
const namespace = 'release-it-lerna-changelog';

Expand Down