Skip to content

Commit

Permalink
Merge pull request #5 from ContinuIT-nl/feat/npm-publish
Browse files Browse the repository at this point in the history
Feat/npm publish
  • Loading branch information
ritsaert authored Jan 6, 2025
2 parents 34d9a96 + 00117a3 commit 60509fa
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ test_output/
.vscode/launch.json
.vscode/settings.json
test_results/test_results.txt
npm/
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ This can be used to ensure that the test report is updated with the current test

## Usage

| Platform | Command |
| -------- | ------------------------------------------------------- |
| npm | `npm install @continuit/testreport` (not yet available) |
| deno | `deno add jsr:@continuit/testreport` |
| Platform | Command |
| -------- | ------------------------------------ |
| npm | `npm install @continuit/testreport` |
| deno | `deno add jsr:@continuit/testreport` |

For other platforms see [jsr.io](https://jsr.io/packages/@continuit/testreport) for more information.

Expand All @@ -34,7 +34,7 @@ Create a test report definition file, for example `testreport.json`:

```json
{
"$schema": "https://github.com/ContinuIT-nl/testreport/blob/main/configSchema/testReportConfigSchema.json",
"$schema": "https://raw.githubusercontent.com/ContinuIT-nl/testreport/refs/heads/main/configSchema/testReportConfigSchema.json",
"input": {
"junit": ["test_results/junit.xml"],
"coverage": ["test_results/cov.lcov"]
Expand Down
56 changes: 56 additions & 0 deletions build.ts
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');
29 changes: 22 additions & 7 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
{
"name": "@continuit/testreport",
"version": "0.1.0",
"version": "0.1.1",
"description": "Generates a test report and badges from your test and coverage results. Allows checking the report in your CI pipeline.",
"repository": "https://github.com/ContinuIT-nl/testreport",
"keywords": [
"test",
"coverage",
"report",
"testreport",
"lcov",
"junit",
"badge"
],
"repository": {
"type": "git",
"url": "git+https://github.com/ContinuIT-nl/testreport.git"
},
"license": "MIT",
"author": "ContinuIT BV, The Netherlands",
"tasks": {
"test": "deno task test_prepare && deno test -RSW --coverage --clean --junit-path test_results/junit.xml && deno coverage --lcov --output=test_results/cov.lcov && deno coverage && deno run -RW ./src/mod.ts ./testreport.json",
"test_prepare": "rm test_results/* && rm -rf test_output && mkdir -p test_output && mkdir -p test_output/deno_success && mkdir -p test_output/deno_disabled && mkdir -p test_output/deno_failed && mkdir -p test_output/jest && mkdir -p test_output/vitest && mkdir -p test_output/no_tests && mkdir -p test_output/invalid_input && mkdir -p test_output/invalid_output",
"test_prepare": "rm -rf test_output && mkdir -p test_output && mkdir -p test_output/deno_success && mkdir -p test_output/deno_disabled && mkdir -p test_output/deno_failed && mkdir -p test_output/jest && mkdir -p test_output/vitest && mkdir -p test_output/no_tests && mkdir -p test_output/invalid_input && mkdir -p test_output/invalid_output",
"create_config_schema": "deno eval 'import { zodToJsonSchema } from \"npm:zod-to-json-schema\"; import { testReportConfigSchema } from \"./src/testReportConfig.ts\"; Deno.writeTextFileSync(\"./configSchema/testReportConfigSchema.json\", JSON.stringify(zodToJsonSchema(testReportConfigSchema), null, 2));'",
"clean": "rm -rf test_output && rm -rf coverage"
"clean": "rm -rf test_output && rm -rf coverage",
"build": "deno run -A build.ts"
},
"imports": {
"@continuit/xmlscanner": "jsr:@continuit/xmlscanner@^1.0.0",
"@std/assert": "jsr:@std/assert@^1.0.10",
"@std/cli": "jsr:@std/cli@^1.0.9",
"@std/encoding": "jsr:@std/encoding@^1.0.6",
"@std/path": "jsr:@std/path@^1.0.8",
"zod": "npm:zod@^3.24.1"
"@valibot/valibot": "jsr:@valibot/valibot@^0.42.1"
},
"exports": "./src/mod.ts",
"publish": {
"include": [
"LICENSE",
"README.md",
"src/**/*.ts"
"src/**/*.ts",
"test_results/*.svg"
]
},
"fmt": {
Expand All @@ -35,7 +49,8 @@
"proseWrap": "preserve",
"useTabs": false,
"exclude": [
"test_results/**/*"
"test_results/**/*",
"npm/**/*"
]
},
"lint": {
Expand Down
129 changes: 117 additions & 12 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/mod.ts
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);
});
Loading

0 comments on commit 60509fa

Please sign in to comment.