Skip to content

Commit

Permalink
setup rollup to build commons
Browse files Browse the repository at this point in the history
  • Loading branch information
epszaw committed Mar 11, 2024
1 parent dea9771 commit d1b80a4
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 19 deletions.
37 changes: 37 additions & 0 deletions .pnp.cjs

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

Binary file not shown.
Binary file not shown.
25 changes: 18 additions & 7 deletions packages/allure-js-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,28 @@
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"./internal": {
"import": "./dist/internal.js",
"require": "./dist/internal.js",
"require": "./dist/internal.cjs",
"types": "./dist/internal.d.ts"
},
"./new": {
"import": "./dist/src/new/index.js",
"require": "./dist/src/new/index.js",
"types": "./dist/src/new/index.d.ts"
"import": "./dist/src/new/framework.js",
"require": "./dist/src/new/framework.cjs",
"types": "./dist/src/new/framework.d.ts"
},
"./new/browser": {
"import": "./dist/src/new/browser/index.js",
"require": "./dist/src/new/browser/index.cjs",
"types": "./dist/src/new/browser/index.d.ts"
},
"./new/node": {
"import": "./dist/src/new/node/index.js",
"require": "./dist/src/new/node/index.cjs",
"types": "./dist/src/new/node/index.d.ts"
}
},
"main": "./dist/index.js",
Expand All @@ -38,7 +48,7 @@
],
"scripts": {
"clean": "rimraf ./dist",
"compile": "tsc",
"compile": "rollup -c",
"lint": "eslint ./src ./index.ts --ext .ts",
"lint:fix": "eslint ./src ./index.ts --ext .ts --fix",
"test": "ts-node --project test/tsconfig.json test/runner.ts"
Expand Down Expand Up @@ -68,11 +78,12 @@
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"expect": "^29.5.0",
"glob": "^10.3.5",
"glob": "^10.3.10",
"mocha": "^10.2.0",
"mocha-multi-reporters": "^1.5.1",
"rimraf": "^5.0.1",
"rollup": "^4.12.1",
"rollup-plugin-dts": "^6.1.0",
"sinon": "^17.0.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
Expand Down
45 changes: 45 additions & 0 deletions packages/allure-js-commons/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import typescript from "@rollup/plugin-typescript";
import { glob } from "glob";
import { join, relative } from "node:path";
import { fileURLToPath } from "node:url";
import { defineConfig } from "rollup";
import dts from "rollup-plugin-dts";

const dirname = fileURLToPath(new URL(".", import.meta.url));

const createRollupEntry = (inputFile, outputFileBase) => [
defineConfig({
input: inputFile,
output: {
file: join(dirname, `${outputFileBase}.js`),
format: "es",
},
plugins: [typescript()],
}),
defineConfig({
input: inputFile,
output: {
file: join(dirname, `${outputFileBase}.d.ts`),
format: "es",
},
plugins: [dts()],
}),
defineConfig({
input: inputFile,
output: {
file: join(dirname, `${outputFileBase}.cjs`),
format: "cjs",
},
plugins: [typescript()],
}),
];

export default () => {
return [
createRollupEntry(join(dirname, "index.ts"), "dist/index"),
createRollupEntry(join(dirname, "internal.ts"), "dist/internal"),
createRollupEntry(join(dirname, "src/new/framework/index.ts"), "dist/new/framework"),
createRollupEntry(join(dirname, "src/new/browser/index.ts"), "dist/new/browser"),
createRollupEntry(join(dirname, "src/new/node/index.ts"), "dist/new/node"),
].flat();
};
12 changes: 1 addition & 11 deletions packages/allure-js-commons/src/new/framework/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import { createHash, randomUUID } from "crypto";
import { Crypto, ExecutableItem, Status } from "../model";

export const crypto: Crypto = {
uuid: () => {
return randomUUID();
},
md5: (str: string) => {
return createHash("md5").update(str).digest("hex");
},
};
import { ExecutableItem, Status } from "../model";

export const isAnyStepFailed = (item: ExecutableItem): boolean => {
const isFailed = item.status === Status.FAILED;
Expand Down
1 change: 1 addition & 0 deletions packages/allure-js-commons/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"internal.ts",
],
"compilerOptions": {
"declaration": false,
"lib": ["dom", "esnext"],
"types": [
"node"
Expand Down
28 changes: 27 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3540,13 +3540,14 @@ __metadata:
eslint-plugin-no-null: ^1.0.2
eslint-plugin-prefer-arrow: ^1.2.3
expect: ^29.5.0
glob: ^10.3.5
glob: ^10.3.10
md5: ^2.3.0
mocha: ^10.2.0
mocha-multi-reporters: ^1.5.1
properties: ^1.2.1
rimraf: ^5.0.1
rollup: ^4.12.1
rollup-plugin-dts: ^6.1.0
sinon: ^17.0.0
source-map-support: ^0.5.21
strip-ansi: ^5.2.0
Expand Down Expand Up @@ -11568,6 +11569,15 @@ __metadata:
languageName: node
linkType: hard

"magic-string@npm:^0.30.4":
version: 0.30.8
resolution: "magic-string@npm:0.30.8"
dependencies:
"@jridgewell/sourcemap-codec": ^1.4.15
checksum: 79922f4500d3932bb587a04440d98d040170decf432edc0f91c0bf8d41db16d364189bf800e334170ac740918feda62cd39dcc170c337dc18050cfcf00a5f232
languageName: node
linkType: hard

"magic-string@npm:^0.30.5":
version: 0.30.7
resolution: "magic-string@npm:0.30.7"
Expand Down Expand Up @@ -14572,6 +14582,22 @@ __metadata:
languageName: node
linkType: hard

"rollup-plugin-dts@npm:^6.1.0":
version: 6.1.0
resolution: "rollup-plugin-dts@npm:6.1.0"
dependencies:
"@babel/code-frame": ^7.22.13
magic-string: ^0.30.4
peerDependencies:
rollup: ^3.29.4 || ^4
typescript: ^4.5 || ^5.0
dependenciesMeta:
"@babel/code-frame":
optional: true
checksum: a90f8e975e4515734c84fa17e0feaf8fdd9ed9368722c3908687875903a393cba4d07d9934bae9b91a0c1b6c63ac1ef0ccd7363d3e6e4dc10eabca3540be9f11
languageName: node
linkType: hard

"rollup@npm:^4.12.1":
version: 4.12.1
resolution: "rollup@npm:4.12.1"
Expand Down

0 comments on commit d1b80a4

Please sign in to comment.