Skip to content

Commit

Permalink
Merge pull request #62 from advanced-security/esm-cli-work
Browse files Browse the repository at this point in the history
Modifications to support conversion from ESM in to CJS for the executables
  • Loading branch information
peter-murray authored Feb 15, 2024
2 parents ed72a32 + 052c08f commit f3cbce2
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 2,111 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib
output

node_modules
target
Expand Down
2,179 changes: 138 additions & 2,041 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
File renamed without changes.
343 changes: 288 additions & 55 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"name": "maven-dependency-submission-action",
"version": "4.0.0",
"description": "Submit Maven dependencies to GitHub dependency submission API",
"type": "module",
"main": "index.js",
"scripts": {
"base-build": "npm ci && tsc",
"build": "npm run base-build && npm exec -- @vercel/ncc build --source-map lib/src/index.js",
"build-exe": "npm run build && pkg package.json --compress Gzip",
"build:cli": "npm run base-build && npm exec -- rollup -c rollup.config.js",
"build-exe": "npm run build:cli && pkg output/cli.js --compress Gzip --out-path cli --targets node18-linux-x64,node18-macos-x64,node18-win-x64",
"test": "vitest --run"
},
"repository": {
Expand All @@ -28,27 +30,19 @@
"packageurl-js": "^1.2.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.1",
"@vercel/ncc": "^0.38.1",
"chai": "^4.3.6",
"pkg": "^5.8.0",
"rollup": "^4.10.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3",
"vitest": "^1.2.1"
},
"bin": {
"cli": "lib/src/executable/cli.js"
},
"pkg": {
"targets": [
"node18-linux-x64",
"node18-win-x64",
"node18-macos-x64"
],
"assets": [
"package.json"
],
"publicPackages": "*",
"outputPath": "cli"
}
}
19 changes: 19 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
input: 'lib/src/executable/cli.js',
output: {
dir: 'output',
format: 'cjs',
exports: 'named',
},
plugins: [
commonjs(),
json(),
nodeResolve({
preferBuiltins: true
})
]
};
2 changes: 1 addition & 1 deletion src/executable/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pkg from '../../package.json';
import { program } from 'commander';

const { program } = require('commander');
program.name(pkg.name);
program.version(pkg.version);

Expand Down
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"compilerOptions": {
"target": "es6",
"module": "ES2020",
"lib": [
"ES2020",
],
"allowSyntheticDefaultImports": true,
"outDir": "./lib",
"sourceRoot": "./src",
"strict": true,
Expand Down

0 comments on commit f3cbce2

Please sign in to comment.