Skip to content

Commit ef2ada2

Browse files
authored
Merge pull request #51 from jsenv/update
update dev files and scripts
2 parents a4560c5 + 742a2f1 commit ef2ada2

10 files changed

Lines changed: 73 additions & 107 deletions

File tree

.github/workflows/main.yml

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,57 @@
1-
# This file configure a GitHub workflow responsible to perform
2-
# various checks related to the codebase.
1+
# This is a GitHub workflow YAML file
2+
# see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
33
#
4-
# For that reason it's runned on every pull request and push to main.
4+
# If you want to update this file it's recommended to use a YAML validator
5+
# https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
6+
# configured to validate with https://json.schemastore.org/github-workflow.json
57
#
6-
# It does the following:
7-
# - Check linting passes (no eslint error on files)
8-
# - Run tests and ensure none is failing
9-
# - Update tests code coverage
8+
# This workflow is responsible to perform various checks related to the codebase,
9+
# For every push to main or on a pull request, it
10+
# - ensures there is no eslint error on files
11+
# - ensures there is no test failing
12+
# - uploads code coverage from tests to codecov
1013
#
11-
# If all these steps are passing the workflow ends up
12-
# publishing package on npm if needed. It will publish the npm package
13-
# using the token found in secrets.NPM_TOKEN. Be sure to create this
14-
# token in the GitHub repository.
14+
# If all these steps are passing and there is a secrets.NPM_TOKEN and version in package.json
15+
# is not already published, workflow published the package on npm.
1516

1617
name: main
1718

1819
on:
1920
push:
2021
branches:
21-
- "**"
22+
- master
2223
pull_request:
2324
branches:
24-
- "master"
25+
- "**"
2526

2627
jobs:
2728
test:
2829
strategy:
2930
matrix:
30-
os: [ubuntu-20.04, macos-10.15, windows-2019]
31+
os: [ubuntu-20.04, macos-10.15, windows-2022]
3132
node: [16.13.0]
3233
runs-on: ${{ matrix.os }}
3334
name: test on ${{ matrix.os }} and node ${{ matrix.node }}
3435
env:
3536
CI: true
3637
steps:
3738
- uses: actions/checkout@v2
38-
- uses: actions/setup-node@v1
39+
- uses: actions/setup-node@v2
3940
with:
4041
node-version: ${{ matrix.node }}
41-
- name: NPM installation
42+
- name: Install node modules
4243
run: npm install
43-
- name: check lint
44-
run: npm run eslint-check
45-
- name: check tests
44+
- name: Generate importmap
45+
run: npm run importmap
46+
- name: Run ESLint
47+
run: npm run eslint
48+
- name: Run tests
4649
run: npm run test-with-coverage
47-
- name: upload coverage
50+
- name: Upload coverage
4851
uses: codecov/codecov-action@v2
4952
with:
5053
token: ${{ secrets.CODECOV_TOKEN }}
54+
# see "coverageJsonFileRelativeUrl" in script/test/test.mjs
5155
files: ./coverage/coverage.json
5256
verbose: true
5357

@@ -58,17 +62,17 @@ jobs:
5862
name: release
5963
steps:
6064
- uses: actions/checkout@v2
61-
- uses: actions/setup-node@v1
65+
- uses: actions/setup-node@v2
6266
with:
6367
node-version: "16.13.0"
64-
- name: npm install
68+
- name: Install node modules
6569
run: npm install
66-
- name: publish package
70+
- name: Publish package
6771
env:
6872
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6973
if: env.NPM_TOKEN != null
7074
run: node ./.github/workflows/main/publish_package.mjs
71-
- name: ensure github release
75+
- name: Ensure GitHub release
7276
env:
7377
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7478
run: node ./.github/workflows/main/github_release.mjs

.github/workflows/performance_impact.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
# "checkout@v2" documentation available at https://github.com/actions/checkout
2626
uses: actions/checkout@v2
2727
- name: Setup node ${{ matrix.node }}
28-
# "setup-node@v1" documentation available at https://github.com/actions/setup-node
29-
uses: actions/setup-node@v1
28+
# "setup-node@v2" documentation available at https://github.com/actions/setup-node
29+
uses: actions/setup-node@v2
3030
with:
3131
node-version: "16.13.0"
32-
- name: Setup npm
32+
- name: Install node modules
3333
run: npm install
3434
- name: Report performance impact
3535
run: node --expose-gc ./.github/workflows/performance_impact/report_performance_impact.mjs

.github/workflows/performance_impact/report_performance_impact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ await reportPerformanceImpact({
1515
logLevel: "debug",
1616
installCommand: "npm install",
1717
performanceReportPath:
18-
"./script/performance/generate_performance_report.mjs#performanceReport",
18+
"./script/performance/performance.mjs#performanceReport",
1919
})

dist/commonjs/jsenv_importmap_node_module.cjs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,11 +2159,7 @@ const tryExportSubpath = async ({
21592159
return filesystem.urlToRelativeUrl(subpathUrl, projectPackageFileUrl);
21602160
};
21612161

2162-
/* global __filename */
2163-
const filenameContainsBackSlashes = __filename.indexOf("\\") > -1;
2164-
const url = filenameContainsBackSlashes ? `file:///${__filename.replace(/\\/g, "/")}` : `file://${__filename}`;
2165-
2166-
const require$1 = node_module.createRequire(url);
2162+
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)));
21672163

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

@@ -3158,25 +3154,6 @@ const writeImportMapFiles = async ({
31583154
}
31593155
}
31603156
}, Promise.resolve());
3161-
Object.keys(importMaps).forEach(key => {
3162-
let importMap = importMaps[key];
3163-
importMap = optimizeImportMap(importMap);
3164-
const importmapFileUrl = filesystem.resolveUrl(key, projectDirectoryUrl);
3165-
importMap = importmap.moveImportMap(importMap, projectDirectoryUrl, importmapFileUrl);
3166-
importMap = importmap.sortImportMap(importMap);
3167-
importMaps[key] = importMap;
3168-
});
3169-
3170-
if (writeFiles) {
3171-
await importMapFileRelativeUrls.reduce(async (previous, importMapFileRelativeUrl) => {
3172-
await previous;
3173-
const importmapFileUrl = filesystem.resolveUrl(importMapFileRelativeUrl, projectDirectoryUrl);
3174-
const importMap = importMaps[importMapFileRelativeUrl];
3175-
await filesystem.writeFile(importmapFileUrl, JSON.stringify(importMap, null, " "));
3176-
logger$1.info(`-> ${filesystem.urlToFileSystemPath(importmapFileUrl)}`);
3177-
}, Promise.resolve());
3178-
}
3179-
31803157
const firstUpdatingJsConfig = importMapFileRelativeUrls.find(importMapFileRelativeUrl => {
31813158
const importMapFileConfig = importMapFiles[importMapFileRelativeUrl];
31823159
return importMapFileConfig.useForJsConfigJSON;
@@ -3202,6 +3179,25 @@ const writeImportMapFiles = async ({
32023179
logger$1.info(`-> ${filesystem.urlToFileSystemPath(jsConfigFileUrl)}`);
32033180
}
32043181

3182+
Object.keys(importMaps).forEach(key => {
3183+
let importMap = importMaps[key];
3184+
importMap = optimizeImportMap(importMap);
3185+
const importmapFileUrl = filesystem.resolveUrl(key, projectDirectoryUrl);
3186+
importMap = importmap.moveImportMap(importMap, projectDirectoryUrl, importmapFileUrl);
3187+
importMap = importmap.sortImportMap(importMap);
3188+
importMaps[key] = importMap;
3189+
});
3190+
3191+
if (writeFiles) {
3192+
await importMapFileRelativeUrls.reduce(async (previous, importMapFileRelativeUrl) => {
3193+
await previous;
3194+
const importmapFileUrl = filesystem.resolveUrl(importMapFileRelativeUrl, projectDirectoryUrl);
3195+
const importMap = importMaps[importMapFileRelativeUrl];
3196+
await filesystem.writeFile(importmapFileUrl, JSON.stringify(importMap, null, " "));
3197+
logger$1.info(`-> ${filesystem.urlToFileSystemPath(importmapFileUrl)}`);
3198+
}, Promise.resolve());
3199+
}
3200+
32053201
return importMaps;
32063202
};
32073203

dist/commonjs/jsenv_importmap_node_module.cjs.map

Lines changed: 7 additions & 10 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "@jsenv/importmap-node-module",
3-
"version": "2.8.0",
3+
"version": "2.8.1",
44
"description": "Generate importmap for node_modules",
55
"license": "MIT",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/jsenv/importmap-node-module"
99
},
1010
"engines": {
11-
"node": ">=14.17.0"
11+
"node": ">=16.13.0"
1212
},
1313
"publishConfig": {
1414
"access": "public"
@@ -27,18 +27,13 @@
2727
"/index.js"
2828
],
2929
"scripts": {
30-
"importmap-generate": "node ./script/importmap/generate_importmap.mjs",
31-
"eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
32-
"prettier-check": "prettier --check .",
33-
"prettier-write": "prettier --write .",
34-
"measure-performances": "node --expose-gc ./script/performance/generate_performance_report.mjs --log",
35-
"dist": "npm run build",
30+
"eslint": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
31+
"importmap": "node ./script/importmap/importmap.mjs",
32+
"performance": "node --expose-gc ./script/performance/performance.mjs --log",
3633
"build": "node --experimental-import-meta-resolve ./script/build/build.mjs",
3734
"test": "node ./script/test/test.mjs",
3835
"test-with-coverage": "npm run test -- --coverage",
39-
"postinstall": "npm run importmap-generate",
40-
"prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
41-
"postpublish": "node ./script/publish/restore_postinstall.mjs"
36+
"prettier": "prettier --write ."
4237
},
4338
"dependencies": {
4439
"@babel/core": "7.16.0",
@@ -51,20 +46,20 @@
5146
"devDependencies": {
5247
"@babel/eslint-parser": "7.16.3",
5348
"@babel/plugin-proposal-class-properties": "7.16.0",
54-
"@babel/plugin-proposal-decorators": "7.16.0",
49+
"@babel/plugin-proposal-decorators": "7.16.4",
5550
"@babel/plugin-syntax-jsx": "7.16.0",
56-
"@jsenv/assert": "2.3.2",
51+
"@jsenv/assert": "2.4.0",
5752
"@jsenv/babel-preset": "1.1.1",
58-
"@jsenv/core": "23.8.7",
53+
"@jsenv/core": "24.5.8",
5954
"@jsenv/eslint-config": "16.0.9",
6055
"@jsenv/github-release-package": "1.2.3",
61-
"@jsenv/importmap-eslint-resolver": "5.1.2",
56+
"@jsenv/importmap-eslint-resolver": "5.2.1",
6257
"@jsenv/package-publish": "1.6.2",
6358
"@jsenv/performance-impact": "2.2.1",
64-
"@jsenv/server": "10.0.11",
65-
"babel-plugin-transform-async-to-promises": "0.8.15",
66-
"eslint": "8.2.0",
59+
"@jsenv/server": "12.2.0",
60+
"babel-plugin-transform-async-to-promises": "0.8.16",
61+
"eslint": "8.4.1",
6762
"eslint-plugin-import": "2.25.3",
68-
"prettier": "2.4.1"
63+
"prettier": "2.5.1"
6964
}
7065
}
File renamed without changes.

script/publish/remove_postinstall.mjs

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

script/publish/restore_postinstall.mjs

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

0 commit comments

Comments
 (0)