Skip to content

Commit

Permalink
Merge pull request #51 from jsenv/update
Browse files Browse the repository at this point in the history
update dev files and scripts
  • Loading branch information
dmail authored Dec 8, 2021
2 parents a4560c5 + 742a2f1 commit ef2ada2
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 107 deletions.
52 changes: 28 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,57 @@
# This file configure a GitHub workflow responsible to perform
# various checks related to the codebase.
# This is a GitHub workflow YAML file
# see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
#
# For that reason it's runned on every pull request and push to main.
# If you want to update this file it's recommended to use a YAML validator
# https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
# configured to validate with https://json.schemastore.org/github-workflow.json
#
# It does the following:
# - Check linting passes (no eslint error on files)
# - Run tests and ensure none is failing
# - Update tests code coverage
# This workflow is responsible to perform various checks related to the codebase,
# For every push to main or on a pull request, it
# - ensures there is no eslint error on files
# - ensures there is no test failing
# - uploads code coverage from tests to codecov
#
# If all these steps are passing the workflow ends up
# publishing package on npm if needed. It will publish the npm package
# using the token found in secrets.NPM_TOKEN. Be sure to create this
# token in the GitHub repository.
# If all these steps are passing and there is a secrets.NPM_TOKEN and version in package.json
# is not already published, workflow published the package on npm.

name: main

on:
push:
branches:
- "**"
- master
pull_request:
branches:
- "master"
- "**"

jobs:
test:
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15, windows-2019]
os: [ubuntu-20.04, macos-10.15, windows-2022]
node: [16.13.0]
runs-on: ${{ matrix.os }}
name: test on ${{ matrix.os }} and node ${{ matrix.node }}
env:
CI: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: NPM installation
- name: Install node modules
run: npm install
- name: check lint
run: npm run eslint-check
- name: check tests
- name: Generate importmap
run: npm run importmap
- name: Run ESLint
run: npm run eslint
- name: Run tests
run: npm run test-with-coverage
- name: upload coverage
- name: Upload coverage
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
# see "coverageJsonFileRelativeUrl" in script/test/test.mjs
files: ./coverage/coverage.json
verbose: true

Expand All @@ -58,17 +62,17 @@ jobs:
name: release
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: "16.13.0"
- name: npm install
- name: Install node modules
run: npm install
- name: publish package
- name: Publish package
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
if: env.NPM_TOKEN != null
run: node ./.github/workflows/main/publish_package.mjs
- name: ensure github release
- name: Ensure GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node ./.github/workflows/main/github_release.mjs
6 changes: 3 additions & 3 deletions .github/workflows/performance_impact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
# "checkout@v2" documentation available at https://github.com/actions/checkout
uses: actions/checkout@v2
- name: Setup node ${{ matrix.node }}
# "setup-node@v1" documentation available at https://github.com/actions/setup-node
uses: actions/setup-node@v1
# "setup-node@v2" documentation available at https://github.com/actions/setup-node
uses: actions/setup-node@v2
with:
node-version: "16.13.0"
- name: Setup npm
- name: Install node modules
run: npm install
- name: Report performance impact
run: node --expose-gc ./.github/workflows/performance_impact/report_performance_impact.mjs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ await reportPerformanceImpact({
logLevel: "debug",
installCommand: "npm install",
performanceReportPath:
"./script/performance/generate_performance_report.mjs#performanceReport",
"./script/performance/performance.mjs#performanceReport",
})
44 changes: 20 additions & 24 deletions dist/commonjs/jsenv_importmap_node_module.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2159,11 +2159,7 @@ const tryExportSubpath = async ({
return filesystem.urlToRelativeUrl(subpathUrl, projectPackageFileUrl);
};

/* global __filename */
const filenameContainsBackSlashes = __filename.indexOf("\\") > -1;
const url = filenameContainsBackSlashes ? `file:///${__filename.replace(/\\/g, "/")}` : `file://${__filename}`;

const require$1 = node_module.createRequire(url);
const require$1 = node_module.createRequire((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('jsenv_importmap_node_module.cjs', document.baseURI).href)));

const traverse = require$1("@babel/traverse");

Expand Down Expand Up @@ -3158,25 +3154,6 @@ const writeImportMapFiles = async ({
}
}
}, Promise.resolve());
Object.keys(importMaps).forEach(key => {
let importMap = importMaps[key];
importMap = optimizeImportMap(importMap);
const importmapFileUrl = filesystem.resolveUrl(key, projectDirectoryUrl);
importMap = importmap.moveImportMap(importMap, projectDirectoryUrl, importmapFileUrl);
importMap = importmap.sortImportMap(importMap);
importMaps[key] = importMap;
});

if (writeFiles) {
await importMapFileRelativeUrls.reduce(async (previous, importMapFileRelativeUrl) => {
await previous;
const importmapFileUrl = filesystem.resolveUrl(importMapFileRelativeUrl, projectDirectoryUrl);
const importMap = importMaps[importMapFileRelativeUrl];
await filesystem.writeFile(importmapFileUrl, JSON.stringify(importMap, null, " "));
logger$1.info(`-> ${filesystem.urlToFileSystemPath(importmapFileUrl)}`);
}, Promise.resolve());
}

const firstUpdatingJsConfig = importMapFileRelativeUrls.find(importMapFileRelativeUrl => {
const importMapFileConfig = importMapFiles[importMapFileRelativeUrl];
return importMapFileConfig.useForJsConfigJSON;
Expand All @@ -3202,6 +3179,25 @@ const writeImportMapFiles = async ({
logger$1.info(`-> ${filesystem.urlToFileSystemPath(jsConfigFileUrl)}`);
}

Object.keys(importMaps).forEach(key => {
let importMap = importMaps[key];
importMap = optimizeImportMap(importMap);
const importmapFileUrl = filesystem.resolveUrl(key, projectDirectoryUrl);
importMap = importmap.moveImportMap(importMap, projectDirectoryUrl, importmapFileUrl);
importMap = importmap.sortImportMap(importMap);
importMaps[key] = importMap;
});

if (writeFiles) {
await importMapFileRelativeUrls.reduce(async (previous, importMapFileRelativeUrl) => {
await previous;
const importmapFileUrl = filesystem.resolveUrl(importMapFileRelativeUrl, projectDirectoryUrl);
const importMap = importMaps[importMapFileRelativeUrl];
await filesystem.writeFile(importmapFileUrl, JSON.stringify(importMap, null, " "));
logger$1.info(`-> ${filesystem.urlToFileSystemPath(importmapFileUrl)}`);
}, Promise.resolve());
}

return importMaps;
};

Expand Down
17 changes: 7 additions & 10 deletions dist/commonjs/jsenv_importmap_node_module.cjs.map

Large diffs are not rendered by default.

33 changes: 14 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@jsenv/importmap-node-module",
"version": "2.8.0",
"version": "2.8.1",
"description": "Generate importmap for node_modules",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jsenv/importmap-node-module"
},
"engines": {
"node": ">=14.17.0"
"node": ">=16.13.0"
},
"publishConfig": {
"access": "public"
Expand All @@ -27,18 +27,13 @@
"/index.js"
],
"scripts": {
"importmap-generate": "node ./script/importmap/generate_importmap.mjs",
"eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
"prettier-check": "prettier --check .",
"prettier-write": "prettier --write .",
"measure-performances": "node --expose-gc ./script/performance/generate_performance_report.mjs --log",
"dist": "npm run build",
"eslint": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
"importmap": "node ./script/importmap/importmap.mjs",
"performance": "node --expose-gc ./script/performance/performance.mjs --log",
"build": "node --experimental-import-meta-resolve ./script/build/build.mjs",
"test": "node ./script/test/test.mjs",
"test-with-coverage": "npm run test -- --coverage",
"postinstall": "npm run importmap-generate",
"prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
"postpublish": "node ./script/publish/restore_postinstall.mjs"
"prettier": "prettier --write ."
},
"dependencies": {
"@babel/core": "7.16.0",
Expand All @@ -51,20 +46,20 @@
"devDependencies": {
"@babel/eslint-parser": "7.16.3",
"@babel/plugin-proposal-class-properties": "7.16.0",
"@babel/plugin-proposal-decorators": "7.16.0",
"@babel/plugin-proposal-decorators": "7.16.4",
"@babel/plugin-syntax-jsx": "7.16.0",
"@jsenv/assert": "2.3.2",
"@jsenv/assert": "2.4.0",
"@jsenv/babel-preset": "1.1.1",
"@jsenv/core": "23.8.7",
"@jsenv/core": "24.5.8",
"@jsenv/eslint-config": "16.0.9",
"@jsenv/github-release-package": "1.2.3",
"@jsenv/importmap-eslint-resolver": "5.1.2",
"@jsenv/importmap-eslint-resolver": "5.2.1",
"@jsenv/package-publish": "1.6.2",
"@jsenv/performance-impact": "2.2.1",
"@jsenv/server": "10.0.11",
"babel-plugin-transform-async-to-promises": "0.8.15",
"eslint": "8.2.0",
"@jsenv/server": "12.2.0",
"babel-plugin-transform-async-to-promises": "0.8.16",
"eslint": "8.4.1",
"eslint-plugin-import": "2.25.3",
"prettier": "2.4.1"
"prettier": "2.5.1"
}
}
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions script/publish/remove_postinstall.mjs

This file was deleted.

10 changes: 0 additions & 10 deletions script/publish/restore_postinstall.mjs

This file was deleted.

0 comments on commit ef2ada2

Please sign in to comment.