Skip to content

Commit

Permalink
chore: require Node.js 14+
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 21, 2022
1 parent 30c2a69 commit c2339ba
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Expand Up @@ -10,10 +10,10 @@ jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 16

- run: npm install
- run: npm run build
Expand All @@ -34,18 +34,17 @@ jobs:

- name: Create Tag
id: create_tag
uses: jaywcjlove/create-tag-action@v1.2.1
uses: jaywcjlove/create-tag-action@v1.3.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
package-path: ./package.json

- name: Generate Changelog
id: changelog
uses: jaywcjlove/changelog-generator@v1.4.6
uses: jaywcjlove/changelog-generator@v1.5.7
with:
token: ${{ secrets.GITHUB_TOKEN }}
head-ref: ${{steps.create_tag.outputs.version}}
filter-author: (小弟调调™|Renovate Bot)
filter-author: (小弟调调™|dependabot|renovate\\[bot\\]|dependabot\\[bot\\]|Renovate Bot)
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'

- name: Create Release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -6,7 +6,7 @@ Add a banner to a string. Get one-line/multi-line comment banner based on packag

## Install

Install with npm:
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): Node 14+ is needed to use it and it must be `import` instead of `require`.

```bash
npm install bannerjs --save
Expand Down
5 changes: 3 additions & 2 deletions bin/cli.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node

const bannerjs = require('../lib');
bannerjs.run();
import { run } from '../lib/index.js';

run();
16 changes: 12 additions & 4 deletions package.json
Expand Up @@ -3,12 +3,14 @@
"version": "2.1.0",
"description": "Get one-line/multi-line comment banner based on package.json.",
"homepage": "https://jaywcjlove.github.io/bannerjs/",
"main": "lib/index.js",
"bin": {
"bannerjs": "./bin/cli.js"
},
"author": "kenny wang <wowohoo@qq.com>",
"license": "MIT",
"type": "module",
"exports": "./index.js",
"types": "./index.d.ts",
"scripts": {
"start": "node lib/index.js",
"watch": "tsbb watch --disable-babel",
Expand All @@ -28,6 +30,9 @@
"src",
"lib"
],
"engines": {
"node": ">=14.16"
},
"keywords": [
"comment",
"banner",
Expand All @@ -41,10 +46,13 @@
"coverageReporters": [
"lcov",
"json-summary"
]
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
}
},
"devDependencies": {
"types-package-json": "2.0.39",
"tsbb": "3.3.7"
"types-package-json": "^2.0.39",
"tsbb": "^3.7.6"
}
}
2 changes: 1 addition & 1 deletion src/cli.ts
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import { createReadStream, createWriteStream } from 'fs';
import { onebanner, multibanner } from './';
import { onebanner, multibanner } from './index.js';

export function run() {
let args = process.argv.slice(2)
Expand Down
13 changes: 8 additions & 5 deletions src/index.ts
@@ -1,14 +1,15 @@
import path from 'path';
import path from 'node:path';
import fs from 'node:fs';
import { PackageJson } from 'types-package-json';

export * from './cli';
export * from './cli.js';

/**
* Get package.json Object
*/
export function getPackage(rootPath: string = process.cwd()): PackageJson {
const pkgPath = path.resolve(rootPath, 'package.json');
const pkg: PackageJson = require(pkgPath);
const pkg: PackageJson = JSON.parse(fs.readFileSync(pkgPath).toString());
pkg.author = pkg.author;
if (pkg.author && typeof pkg.author === 'object' && pkg.author.name) {
pkg.author = pkg.author.name;
Expand Down Expand Up @@ -51,10 +52,12 @@ export function multibanner(option?: PackageJson) {
return [
'/**!',
'\n *', bn.name, bn.version && `v${bn.version}`,
'\n *', bn.description,
bn.description && `\n * ${bn.description}`,
'\n *',
`\n * Copyright (c) ${new Date().getFullYear()}`, bn.author,
'\n *', bn.homepage,
'\n *', bn.repository && bn.repository.url && bn.repository.url,
'\n *',
bn.homepage && `\n * @website: ${bn.homepage}\n`,
'\n *', bn.license && `Licensed under the ${bn.license} license`,
'\n */\n'
].filter(Boolean).join(' ');
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "ESNext",
"target": "ESNext",
"esModuleInterop": true,
"declaration": true,
"target": "es2017",
"noImplicitAny": true,
"resolveJsonModule": true,
"moduleResolution": "node",
Expand Down

0 comments on commit c2339ba

Please sign in to comment.