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

feat!: using node14 with type:module #434

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 9
},
"rules": {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12, 14]
node: [14.15.1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only one version is tested, a matrix is not needed. But it may still be useful to test in different Node.js versions.

Also, I believe 14 would use the latest 14 version, so we don't need to set the complete version. (same below and in .npmrc)

name: Test on Node.js ${{ matrix.node }}
steps:
- name: Checkout
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.18.1
14.15.1
13 changes: 13 additions & 0 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
plugins: ['@babel/plugin-proposal-optional-chaining'],
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
};
12 changes: 0 additions & 12 deletions babel.config.js

This file was deleted.

File renamed without changes.
9 changes: 5 additions & 4 deletions lib/builder.js
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
8 changes: 4 additions & 4 deletions lib/export-resume.js
Original file line number Diff line number Diff line change
@@ -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,
) => {
Expand Down
5 changes: 2 additions & 3 deletions lib/init.js
Original file line number Diff line number Diff line change
@@ -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)) {
Expand Down
23 changes: 11 additions & 12 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 4 additions & 4 deletions lib/serve.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/test-utils/cli-test-entry.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
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';

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';
12 changes: 6 additions & 6 deletions lib/test-utils/mocked-volume-builder.js
Original file line number Diff line number Diff line change
@@ -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' }),
Expand Down Expand Up @@ -42,4 +43,3 @@ module.exports = ({ mount = '/' } = {}) => {
),
mount,
);
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "0.0.0-development",
"description": "The JSON Resume command line interface",
"main": "index.js",
"type": "module",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be in the published package.json once we compile the source with Babel? Not sure anyone is importing resume-cli, but still.

"engines": {
"node": ">=10.18.1"
"node": ">=14.15.1"
},
"files": [
"index.js",
Expand All @@ -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",
Expand Down