Skip to content

Commit

Permalink
Merge pull request #158 from rwjblue/migrate-to-esm
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Oct 15, 2021
2 parents a42adf6 + a8b3cc7 commit 59ec228
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 77 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js → .eslintrc.cjs
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
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
@@ -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
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
@@ -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

0 comments on commit 59ec228

Please sign in to comment.