Skip to content

Commit 42683e8

Browse files
authored
Merge pull request #306 from h5bp/esm-modules
ESM + Tests + Making Everything Green
2 parents 3b69113 + 70e68b2 commit 42683e8

File tree

11 files changed

+76
-91
lines changed

11 files changed

+76
-91
lines changed
File renamed without changes.

.github/workflows/coverage.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Tests and coverage
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 16.x
19+
cache: "npm"
20+
- run: npm install
21+
- run: npm run coverage
22+
- uses: codecov/codecov-action@v3

.github/workflows/coveralls.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,10 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- name: Get npm cache directory
18-
id: npm-cache
19-
run: |
20-
echo "::set-output name=dir::$(npm config get cache)"
21-
- uses: actions/cache@v3
22-
with:
23-
path: ${{ steps.npm-cache.outputs.dir }}
24-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
25-
restore-keys: |
26-
${{ runner.os }}-node-
2717
- uses: actions/checkout@v3
2818
- name: Use Node.js ${{ matrix.node-version }}
2919
uses: actions/setup-node@v3
3020
with:
3121
node-version: "16.x"
32-
- run: npm ci
22+
- run: npm install
3323
- run: npm run lint

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create HTML5 Boilerplate
22

3-
[![Coverage Status](https://coveralls.io/repos/github/h5bp/create-html5-boilerplate/badge.svg?branch=master)](https://coveralls.io/github/h5bp/create-html5-boilerplate?branch=master)
3+
[![codecov](https://codecov.io/gh/h5bp/create-html5-boilerplate/branch/master/graph/badge.svg?token=H8V43VURZJ)](https://codecov.io/gh/h5bp/create-html5-boilerplate)
44
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
55
[![Total alerts](https://img.shields.io/lgtm/alerts/g/h5bp/create-html5-boilerplate.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/h5bp/create-html5-boilerplate/alerts/)
66

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
#!/usr/bin/env node
2-
require("./lib/cli")(process.argv.slice(2)).catch(console.error);
2+
// eslint-disable-next-line import/extensions
3+
import cli from "./lib/cli.js";
4+
5+
cli(process.argv.slice(2)).catch(console.error);

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
transform: {},
3+
moduleNameMapper: {
4+
chalk: "chalk/source/index.js",
5+
"#ansi-styles": "chalk/source/vendor/ansi-styles/index.js",
6+
"#supports-color": "chalk/source/vendor/supports-color/index.js",
7+
},
8+
};

lib/cli.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
const yargsParser = require("yargs-parser");
2-
const path = require("path");
3-
const chalk = require("chalk");
4-
const inquirer = require("inquirer");
5-
const fuzzy = require("fuzzy");
6-
const ora = require("ora");
7-
const { extract } = require("pacote");
8-
const glob = require("fast-glob");
9-
const fs = require("fs-extra");
10-
const os = require("os");
1+
import yargsParser from "yargs-parser";
2+
import path from "path";
3+
import chalk from "chalk";
4+
import inquirer from "inquirer";
5+
import fuzzy from "fuzzy";
6+
import ora from "ora";
7+
import pacote from "pacote";
8+
import glob from "fast-glob";
9+
import fs from "fs-extra";
10+
import os from "os";
11+
import elapsed from "elapsed-time-logger";
12+
import compareVersions from "compare-versions";
13+
import inqurerAutocompletePrompt from "inquirer-autocomplete-prompt";
14+
15+
const extract = (a, b, c) => pacote.extract(a, b, c);
1116

1217
const packageName = "html5-boilerplate";
1318
const tempDir = `${os.tmpdir()}/${packageName}-staging`;
14-
const elapsed = require("elapsed-time-logger");
15-
const compareVersions = require("compare-versions");
16-
const langsList = require("./countries.json");
1719

1820
let spinner;
19-
inquirer.registerPrompt(
20-
"autocomplete",
21-
require("inquirer-autocomplete-prompt")
22-
);
21+
inquirer.registerPrompt("autocomplete", inqurerAutocompletePrompt);
2322

2423
const checkFolder = async (targetDir, argv) => {
2524
const folderExists = await fs.pathExists(targetDir);
@@ -58,6 +57,10 @@ const onLoad = async (targetDir, version, argv) => {
5857
if (skipPrompts) {
5958
return;
6059
}
60+
const langsList = JSON.parse(
61+
await fs.readFile(new URL("./countries.json", import.meta.url))
62+
);
63+
6164
const langListMap = {};
6265
const langListOut = [];
6366
/* istanbul ignore if */
@@ -118,7 +121,7 @@ const onLoad = async (targetDir, version, argv) => {
118121
}
119122
};
120123

121-
module.exports = async (argvs) => {
124+
export default async function CreateHtml5BoilerplateCLI(argvs) {
122125
const argv = yargsParser(argvs, {
123126
alias: { release: ["r"], yes: ["y"] },
124127
});
@@ -165,4 +168,4 @@ module.exports = async (argvs) => {
165168
} finally {
166169
await fs.remove(tempDir);
167170
}
168-
};
171+
}

package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
"license": "MIT",
1515
"author": "@h5bp",
1616
"main": "index.js",
17+
"type": "module",
1718
"bin": {
1819
"create-html5-boilerplate": "./index.js"
1920
},
2021
"scripts": {
21-
"test": "jest",
22+
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
2223
"lint": "eslint lib/cli.js",
2324
"format": "prettier --write \"./cli.js\" \"tests/*.js\"",
24-
"coverage": "jest --coverage --collectCoverageOnlyFrom ./lib/cli.js",
25+
"coverage": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage --collectCoverageOnlyFrom ./lib/cli.js",
2526
"semantic-release": "semantic-release"
2627
},
2728
"files": [

0 commit comments

Comments
 (0)