From f155cb6957d21797ea7325b9b976ad895e31021d Mon Sep 17 00:00:00 2001 From: antialias Date: Sat, 28 Nov 2020 08:18:49 -0600 Subject: [PATCH] node@14 LTS --- .eslintrc.json | 1 + .github/workflows/main.yml | 4 ++-- .nvmrc | 2 +- babel.config.cjs | 13 +++++++++++++ babel.config.js | 12 ------------ jest.config.js => jest.config.cjs | 0 lib/builder.js | 9 +++++---- lib/export-resume.js | 8 ++++---- lib/init.js | 5 ++--- lib/main.js | 23 +++++++++++------------ lib/serve.js | 8 ++++---- lib/test-utils/cli-test-entry.js | 6 ++++-- lib/test-utils/mocked-volume-builder.js | 12 ++++++------ package.json | 5 +++-- 14 files changed, 56 insertions(+), 52 deletions(-) create mode 100644 babel.config.cjs delete mode 100644 babel.config.js rename jest.config.js => jest.config.cjs (100%) diff --git a/.eslintrc.json b/.eslintrc.json index da1c11ab..b01df64c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -17,6 +17,7 @@ ], "parser": "@babel/eslint-parser", "parserOptions": { + "sourceType": "module", "ecmaVersion": 9 }, "rules": { diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b93d713b..99875476 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [10, 12, 14] + node: [14.15.1] name: Test on Node.js ${{ matrix.node }} steps: - name: Checkout @@ -37,7 +37,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v1 with: - node-version: 12 + node-version: 14.15.1 - name: Install run: npm ci diff --git a/.nvmrc b/.nvmrc index fd26bfb7..2f5ee741 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -10.18.1 +14.15.1 diff --git a/babel.config.cjs b/babel.config.cjs new file mode 100644 index 00000000..9ba719cc --- /dev/null +++ b/babel.config.cjs @@ -0,0 +1,13 @@ +module.exports = { + plugins: ['@babel/plugin-proposal-optional-chaining'], + presets: [ + [ + '@babel/preset-env', + { + targets: { + node: 'current', + }, + }, + ], + ], +}; diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 37a5bd05..00000000 --- a/babel.config.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - plugins: ["@babel/plugin-proposal-optional-chaining"], - presets: [ - [ - "@babel/preset-env", - { - targets: { - node: true - } - } - ]] -} diff --git a/jest.config.js b/jest.config.cjs similarity index 100% rename from jest.config.js rename to jest.config.cjs diff --git a/lib/builder.js b/lib/builder.js index efca364e..6b7506c9 100644 --- a/lib/builder.js +++ b/lib/builder.js @@ -1,9 +1,10 @@ +import fs from 'fs'; +import request from 'superagent'; +import chalk from 'chalk'; +import renderHtml from './render-html'; + const themeServer = process.env.THEME_SERVER || 'https://themes.jsonresume.org/theme/'; -const fs = require('fs'); -const request = require('superagent'); -const chalk = require('chalk'); -const renderHtml = require('./render-html'); const denormalizeTheme = (value) => { return value.match(/jsonresume-theme-(.*)/)[1]; diff --git a/lib/export-resume.js b/lib/export-resume.js index b340eebd..73651eca 100644 --- a/lib/export-resume.js +++ b/lib/export-resume.js @@ -1,13 +1,13 @@ import renderHTML from './render-html'; import { promisify } from 'util'; import fs from 'fs'; +import path from 'path'; +import puppeteer from 'puppeteer'; +import btoa from 'btoa'; const writeFile = promisify(fs.writeFile); -const path = require('path'); -const puppeteer = require('puppeteer'); -const btoa = require('btoa'); -module.exports = ( +export default ( { resume: resumeJson, fileName, theme, format }, callback, ) => { diff --git a/lib/init.js b/lib/init.js index 913c4910..1232f071 100644 --- a/lib/init.js +++ b/lib/init.js @@ -1,14 +1,13 @@ +import read from 'read'; import { promisify } from 'util'; import fs from 'fs'; import chalk from 'chalk'; import yesno from 'yesno'; import { set } from 'object-path-immutable'; import exists from 'file-exists'; -import readCB from 'read'; const writeFile = promisify(fs.writeFile); -const read = promisify(readCB); -const resume = require('resume-schema/sample.resume.json'); +import resume from 'resume-schema/sample.resume.json'; export default async ({ resumePath }) => { if (await exists(resumePath)) { diff --git a/lib/main.js b/lib/main.js index e72db6fa..ab57acdd 100755 --- a/lib/main.js +++ b/lib/main.js @@ -1,18 +1,17 @@ #!/usr/bin/env node -import 'dotenv/config'; +import 'dotenv/config.js'; -import init from './init'; -import getResume from './get-resume'; -import getSchema from './get-schema'; -import validate from './validate'; - -const pkg = require('../package.json'); -const exportResume = require('./export-resume'); -const serve = require('./serve'); -const program = require('commander'); -const chalk = require('chalk'); -const path = require('path'); +import init from './init.js'; +import getResume from './get-resume.js'; +import getSchema from './get-schema.js'; +import validate from './validate.js'; +import pkg from '../package.json'; +import program from 'commander'; +import chalk from 'chalk'; +import path from 'path'; +import exportResume from './export-resume.js'; +import serve from './serve.js'; const normalizeTheme = (value, defaultValue) => { const theme = value || defaultValue; diff --git a/lib/serve.js b/lib/serve.js index c681bc2e..1e96a457 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1,9 +1,9 @@ -const fs = require('fs'); -const path = require('path'); -const readline = require('readline'); +import fs from 'fs'; +import path from 'path'; +import readline from 'readline'; const bs = require('browser-sync').create(); -const builder = require('./builder'); +import builder from './builder'; const reBuildResume = (theme, dir, resumeFilename, cb) => { builder(theme, dir, resumeFilename, (err, html) => { diff --git a/lib/test-utils/cli-test-entry.js b/lib/test-utils/cli-test-entry.js index 40e1ee2a..6d898de8 100644 --- a/lib/test-utils/cli-test-entry.js +++ b/lib/test-utils/cli-test-entry.js @@ -1,4 +1,4 @@ -import build from './mocked-volume-builder'; +import build from './mocked-volume-builder.js'; import { patchFs } from 'fs-monkey'; import { ufs } from 'unionfs'; import * as fs from 'fs'; @@ -6,7 +6,9 @@ import * as fs from 'fs'; const mockVolume = build({ mount: '/test-resumes' }); const vol = ufs.use(mockVolume).use(fs); patchFs(vol); -require('../main.js'); + process.once('beforeExit', () => { process.send({ data: mockVolume.toJSON(), type: 'volumeExport' }); }); + +import '../main.js'; diff --git a/lib/test-utils/mocked-volume-builder.js b/lib/test-utils/mocked-volume-builder.js index 18eddf6d..c9db6f4d 100644 --- a/lib/test-utils/mocked-volume-builder.js +++ b/lib/test-utils/mocked-volume-builder.js @@ -1,8 +1,9 @@ -module.exports = ({ mount = '/' } = {}) => { - const dedent = require('dedent'); - const flat = require('flat'); - const { Volume } = require('memfs'); - return Volume.fromJSON( +import dedent from 'dedent'; +import flat from 'flat'; +import { Volume } from 'memfs'; + +export default ({ mount = '/' } = {}) => + Volume.fromJSON( flat( { 'only-number-schema.json': JSON.stringify({ type: 'number' }), @@ -42,4 +43,3 @@ module.exports = ({ mount = '/' } = {}) => { ), mount, ); -}; diff --git a/package.json b/package.json index 76b01b30..5e9e2869 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "version": "0.0.0-development", "description": "The JSON Resume command line interface", "main": "index.js", + "type": "module", "engines": { - "node": ">=10.18.1" + "node": ">=14.15.1" }, "files": [ "index.js", @@ -19,7 +20,7 @@ "prepublishOnly": "pinst --disable", "postpublish": "pinst --enable", "prepare": "babel lib -d build --copy-files", - "test": "jest" + "test": "node --experimental-vm-modules node_modules/.bin/jest" }, "repository": { "type": "git",