-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ContinuIT-nl/feat/npm-publish
Feat/npm publish
- Loading branch information
Showing
12 changed files
with
298 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ test_output/ | |
.vscode/launch.json | ||
.vscode/settings.json | ||
test_results/test_results.txt | ||
npm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { build, stop } from 'npm:[email protected]'; | ||
import { denoPlugins } from 'jsr:@luca/esbuild-deno-loader@^0.11.1'; | ||
|
||
await Deno.mkdir('npm', { recursive: true }); | ||
|
||
const result = await build({ | ||
plugins: [...denoPlugins()], | ||
entryPoints: ['./src/mod.ts'], | ||
outfile: './npm/bundle.mjs', | ||
bundle: true, | ||
format: 'esm', | ||
minify: false, | ||
sourcemap: true, | ||
}); | ||
|
||
console.log('build result', result.outputFiles); | ||
|
||
await stop(); | ||
|
||
// copy over README.md and LICENSE | ||
await Deno.copyFile('README.md', 'npm/README.md'); | ||
await Deno.copyFile('LICENSE', 'npm/LICENSE'); | ||
|
||
// Read in deno.json and generate a package.json | ||
const denoJsonText = await Deno.readTextFile('deno.json'); | ||
const denoJson = JSON.parse(denoJsonText); | ||
const packageJson = { | ||
name: denoJson.name, | ||
version: denoJson.version, | ||
description: denoJson.description, | ||
keywords: denoJson.keywords, | ||
author: denoJson.author, | ||
license: denoJson.license, | ||
type: 'commonjs', | ||
homepage: denoJson.homepage, | ||
repository: denoJson.repository, | ||
bin: { | ||
testreport: './bundle.mjs', | ||
}, | ||
main: './bundle.mjs', | ||
files: [ | ||
'README.md', | ||
'LICENSE', | ||
'bundle.mjs', | ||
'bundle.mjs.map', | ||
'test_results/test_badge.svg', | ||
'test_results/coverage_badge.svg', | ||
], | ||
}; | ||
await Deno.writeTextFile('npm/package.json', JSON.stringify(packageJson, null, 2)); | ||
|
||
await Deno.mkdir('npm/test_results', { recursive: true }); | ||
await Deno.copyFile('./test_results/test_badge.svg', 'npm/test_results/test_badge.svg'); | ||
await Deno.copyFile('./test_results/coverage_badge.svg', 'npm/test_results/coverage_badge.svg'); | ||
|
||
console.log('build complete'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import * as process from 'node:process'; | ||
import { execute } from './execute.ts'; | ||
|
||
if (import.meta.main) { | ||
process.exit(await execute(process.argv.slice(2))); | ||
} | ||
execute(process.argv.slice(2)).then((exitCode) => { | ||
process.exit(exitCode); | ||
}).catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.