@epikodelabs/testify 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +686 -0
- package/assets/favicon.ico +0 -0
- package/bin/jasmine +1053 -0
- package/bin/testify +4640 -0
- package/esm-loader.mjs +332 -0
- package/lib/index.js +231 -0
- package/package.json +89 -0
- package/postinstall.mjs +161 -0
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "child_process";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import os from "os";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
const platform = os.platform();
|
|
11
|
+
const arch = os.arch();
|
|
12
|
+
|
|
13
|
+
// -------------------- Utility --------------------
|
|
14
|
+
function run(cmd, cwd = __dirname, env = process.env) {
|
|
15
|
+
console.log(`> ${cmd}`);
|
|
16
|
+
const result = spawnSync(cmd, {
|
|
17
|
+
shell: true,
|
|
18
|
+
stdio: "inherit",
|
|
19
|
+
cwd,
|
|
20
|
+
env,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (result.error) {
|
|
24
|
+
console.error("[postinstall] Command failed:", result.error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (result.status !== 0) {
|
|
29
|
+
console.error(`[postinstall] Exited with code ${result.status}`);
|
|
30
|
+
process.exit(result.status);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getPackageVersion(pkgName) {
|
|
37
|
+
const pkgPath = path.join(__dirname, "package.json");
|
|
38
|
+
|
|
39
|
+
if (!fs.existsSync(pkgPath)) {
|
|
40
|
+
throw new Error("package.json not found in postinstall directory");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
44
|
+
const version =
|
|
45
|
+
pkg.dependencies?.[pkgName] || pkg.devDependencies?.[pkgName];
|
|
46
|
+
|
|
47
|
+
if (!version) {
|
|
48
|
+
throw new Error(`Cannot find version for ${pkgName}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return version.replace(/^[^0-9]*/, "");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// -------------------- DEPENDENCIES --------------------
|
|
55
|
+
function installBundleDependencies() {
|
|
56
|
+
const pkgPath = path.join(__dirname, "package.json");
|
|
57
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
58
|
+
const bundleDeps = pkg.bundleDependencies?.length
|
|
59
|
+
? pkg.bundleDependencies
|
|
60
|
+
: Object.keys(pkg.dependencies || {});
|
|
61
|
+
|
|
62
|
+
if (!bundleDeps.length) {
|
|
63
|
+
console.log("[postinstall] No bundle dependencies declared, skipping.");
|
|
64
|
+
return bundleDeps;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const specs = bundleDeps.map((name) => `${name}@${getPackageVersion(name)}`);
|
|
68
|
+
run(`npm install --no-save ${specs.join(" ")}`);
|
|
69
|
+
return bundleDeps;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// -------------------- ESBUILD --------------------
|
|
73
|
+
function installEsbuild() {
|
|
74
|
+
const version = getPackageVersion("esbuild");
|
|
75
|
+
let pkg;
|
|
76
|
+
|
|
77
|
+
switch (platform) {
|
|
78
|
+
case "win32":
|
|
79
|
+
pkg = `@esbuild/win32-x64@${version}`;
|
|
80
|
+
break;
|
|
81
|
+
case "linux":
|
|
82
|
+
pkg = arch === "x64"
|
|
83
|
+
? `@esbuild/linux-x64@${version}`
|
|
84
|
+
: `@esbuild/linux-arm64@${version}`;
|
|
85
|
+
break;
|
|
86
|
+
case "darwin":
|
|
87
|
+
pkg = arch === "arm64"
|
|
88
|
+
? `@esbuild/darwin-arm64@${version}`
|
|
89
|
+
: `@esbuild/darwin-x64@${version}`;
|
|
90
|
+
break;
|
|
91
|
+
default:
|
|
92
|
+
console.warn("[postinstall] Unsupported platform for esbuild");
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
run(`npm install ${pkg} --no-save`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// -------------------- ROLLUP --------------------
|
|
100
|
+
function installRollup() {
|
|
101
|
+
let pkg;
|
|
102
|
+
|
|
103
|
+
switch (platform) {
|
|
104
|
+
case "win32":
|
|
105
|
+
pkg = "@rollup/rollup-win32-x64-msvc";
|
|
106
|
+
break;
|
|
107
|
+
case "linux":
|
|
108
|
+
pkg = arch === "x64"
|
|
109
|
+
? "@rollup/rollup-linux-x64-gnu"
|
|
110
|
+
: "@rollup/rollup-linux-arm64-gnu";
|
|
111
|
+
break;
|
|
112
|
+
case "darwin":
|
|
113
|
+
pkg = arch === "arm64"
|
|
114
|
+
? "@rollup/rollup-darwin-arm64"
|
|
115
|
+
: "@rollup/rollup-darwin-x64";
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
console.warn("[postinstall] Unsupported platform for rollup");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
run(`npm install ${pkg} --no-save`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// -------------------- PLAYWRIGHT --------------------
|
|
126
|
+
function installPlaywright() {
|
|
127
|
+
const useBundled = process.env.PLAYWRIGHT_BROWSERS_PATH === "0";
|
|
128
|
+
|
|
129
|
+
console.log(
|
|
130
|
+
`[postinstall] Installing Playwright browsers (${useBundled ? "bundled" : "global"} mode)`
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// Install browsers
|
|
134
|
+
if (useBundled) {
|
|
135
|
+
run("PLAYWRIGHT_BROWSERS_PATH=0 npx playwright install");
|
|
136
|
+
} else {
|
|
137
|
+
run("npx playwright install");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// -------------------- MAIN --------------------
|
|
142
|
+
try {
|
|
143
|
+
const bundleDeps = installBundleDependencies();
|
|
144
|
+
|
|
145
|
+
if (bundleDeps.includes("esbuild")) {
|
|
146
|
+
installEsbuild();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (bundleDeps.includes("rollup")) {
|
|
150
|
+
installRollup();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (bundleDeps.includes("playwright")) {
|
|
154
|
+
installPlaywright();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
console.log("[postinstall] Completed successfully.");
|
|
158
|
+
} catch (e) {
|
|
159
|
+
console.error("[postinstall] ERROR:", e);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|