Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c6429cd
test: add angular test matrix
Orkuncakilkaya May 15, 2026
b46b7f3
test: add gen project version command before tests ran
Orkuncakilkaya May 15, 2026
72c94fb
Merge branch 'main' into angular-test-matrix
Orkuncakilkaya Jun 22, 2026
5e5762c
refactor: test-matrix bash to javascript
Orkuncakilkaya Jun 23, 2026
64e83d8
refactor: node version and ci workflow adaptation
Orkuncakilkaya Jun 23, 2026
e7b9c06
refactor: ensure jest, build and dependencies for each major
Orkuncakilkaya Jun 23, 2026
360c7c0
refactor: if else blocks to map
Orkuncakilkaya Jun 23, 2026
f0efde5
refactor: remove redundant fs wrappers
Orkuncakilkaya Jun 24, 2026
638125b
refactor: throw error if pnpm not installed
Orkuncakilkaya Jun 24, 2026
a995db2
refactor: remove CI from hardcoded env
Orkuncakilkaya Jun 24, 2026
3de9b6e
refactor: remove redundant main wrapper function
Orkuncakilkaya Jun 24, 2026
f16e4d8
refactor: simplify test matrix
Orkuncakilkaya Jun 24, 2026
bfd5faf
refactor: adjust angular tag logic and update pnpm version in CI work…
Orkuncakilkaya Jun 24, 2026
be5df1e
refactor: remove redundant comments
Orkuncakilkaya Jun 24, 2026
5591907
chore: run gen version before test matrix
Orkuncakilkaya Jun 30, 2026
b5edb34
refactor: update pnpm-workspace with allowBuilds configuration
Orkuncakilkaya Jul 1, 2026
8bf21af
refactor: update dependencies and adjust test matrix configuration
Orkuncakilkaya Jul 1, 2026
90385bb
refactor: migrate to TypeScript, simplify metadata handling, and upda…
Orkuncakilkaya Jul 1, 2026
8ee86ea
refactor: handle child process errors in helpers
Orkuncakilkaya Jul 1, 2026
555f08b
refactor: use `parseArgs` for version argument parsing in test matrix
Orkuncakilkaya Jul 1, 2026
16c8627
refactor: simplify package installation logic
Orkuncakilkaya Jul 1, 2026
5d6e9db
refactor: update pnpm version to 11 in CI workflow
Orkuncakilkaya Jul 1, 2026
f8250fa
refactor: revert - downgrade pnpm version to 9 in CI workflow to work…
Orkuncakilkaya Jul 1, 2026
2aa6e79
refactor: revert lock file
Orkuncakilkaya Jul 1, 2026
46a789e
refactor: install ts dependencies for ci
Orkuncakilkaya Jul 1, 2026
27c067c
refactor: update frozen lockfile
Orkuncakilkaya Jul 1, 2026
3f19ff1
refactor: adapt for pnpm v11
Orkuncakilkaya Jul 1, 2026
c37d012
refactor: adapt for pnpm v9
Orkuncakilkaya Jul 1, 2026
dcf8d4a
refactor: simplify test matrix version argument in CI workflow
Orkuncakilkaya Jul 1, 2026
5569568
refactor: remove property from Angular metadata
Orkuncakilkaya Jul 7, 2026
1539abb
refactor: remove version generation step from CI test matrix workflow
Orkuncakilkaya Jul 7, 2026
e2995a7
refactor: adjust concurrency in test-matrix workflow
Orkuncakilkaya Jul 7, 2026
3c640a6
chore: try concurrency with new push
Orkuncakilkaya Jul 7, 2026
40747e1
chore: separate preload and home page
Orkuncakilkaya Jun 22, 2026
1dea6a0
chore: separate preload and home page for root demo
Orkuncakilkaya Jun 22, 2026
2e25349
docs(readme): environment.dev.ts in readme for angular21
Orkuncakilkaya Jun 22, 2026
7d583f7
docs(readme): update instructions for anguar21 demo app
Orkuncakilkaya Jun 23, 2026
b470170
chore(ci): update coverage workflow to use coveralls
Orkuncakilkaya Jul 3, 2026
a7dea1e
refactor: set package manager version
Orkuncakilkaya Jul 3, 2026
514f3d4
refactor: use pnpm@9 to support older angular versions
Orkuncakilkaya Jul 3, 2026
4cf5620
chore(ci): standardize step names in coverage workflow
Orkuncakilkaya Jul 3, 2026
a0c0794
chore(ci): specify ubuntu-latest for coverage workflow
Orkuncakilkaya Jul 3, 2026
ed221dc
test: add unit tests for server-specific behavior and public API exports
Orkuncakilkaya Jul 3, 2026
7c43d1c
chore: use required inputs for coveralls workflow
Orkuncakilkaya Jul 3, 2026
3edeeed
chore: honor CI pnpm install step
Orkuncakilkaya Jul 3, 2026
c721d1f
chore(ci): update permissions for coverage workflow
Orkuncakilkaya Jul 3, 2026
7c6bd70
chore: remove unnecessary allowBuilds configuration in pnpm-workspace…
Orkuncakilkaya Jul 7, 2026
55a2daa
chore: use package.json for pnpm version
Orkuncakilkaya Jul 13, 2026
bf7b071
chore: fix lock file
Orkuncakilkaya Jul 13, 2026
45c4c2e
chore: use main branch lock file
Orkuncakilkaya Jul 13, 2026
0accde1
chore: use fresh lock file
Orkuncakilkaya Jul 13, 2026
56eb381
Merge branch 'main' into angular-test-matrix
Orkuncakilkaya Jul 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test Angular Matrix

on:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
test-matrix:
Comment thread
JuroUhlar marked this conversation as resolved.
name: Angular ${{ matrix.angular }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- angular: 15
node: 18
- angular: 16
node: 18
- angular: 17
node: 18
- angular: 18
node: 20
- angular: 19
node: 20
- angular: 20
node: 20
- angular: 21
Comment thread
JuroUhlar marked this conversation as resolved.
node: 22

steps:
- uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm install

- name: Run Matrix Check for Angular ${{ matrix.angular }}
run: pnpm run test:matrix --version=${{ matrix.angular }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
/tmp
/out-tsc
/bazel-out
.pnpm-store
projects/*/dist
projects/*/out-tsc

# Node
node_modules
npm-debug.log
yarn-error.log
test-logs

# IDEs and editors
.idea/
Expand Down
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
188 changes: 188 additions & 0 deletions bin/test-matrix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import * as fs from 'fs'
import * as path from 'path'
import * as os from 'os'
import { angularMetadata } from './utils/angularMetadata'
import { setupLogDir, executeCommand, updateJsonFile } from './utils/helpers'
import { parseArgs } from 'node:util'

const LIB_NAME = 'fingerprintjs-pro-angular'
const LOG_DIR = path.join(process.cwd(), 'test-logs')

process.env['NG_CLI_ANALYTICS'] = 'false'

async function testVersion(version: string): Promise<number> {
const meta = angularMetadata[version]
if (!meta) {
const errorMsg = `No metadata found for version ${version}`
console.error(errorMsg)
const logFile = path.join(LOG_DIR, `angular-${version}.log`)
fs.writeFileSync(logFile, errorMsg)
return 1
}

const logFile = path.join(LOG_DIR, `angular-${version}.log`)
const logStream = fs.createWriteStream(logFile)
const log = (data: string) => logStream.write(data)

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'angular-test-'))
const workspaceDir = path.join(tempDir, 'test-workspace')

try {
log(`Angular ${version}: Starting check...\n`)
console.log(`Angular ${version}: Starting check...`)

await executeCommand(
'npx',
[
'-y',
`@angular/cli@${version}`,
'new',
'test-workspace',
'--create-application=false',
'--skip-git',
'--skip-install',
'--defaults',
'--package-manager=pnpm',
],
{ cwd: tempDir, env: { ...process.env } },
log
)

await executeCommand(
'npx',
['-y', `@angular/cli@${version}`, 'generate', 'library', LIB_NAME, '--skip-install'],
{ cwd: workspaceDir, env: { ...process.env } },
log
)

const angularVersionTag = parseInt(version) > 15 ? `v${version}-lts` : `^${version}`

const extraPackagesToInstall = [`zone.js@${meta.zone}`, `@angular/platform-browser-dynamic@${angularVersionTag}`]

const jestVersion = meta.jest
const typesJestVersion = meta.typesJest || jestVersion

const extraDevPackagesToInstall = [
'@fingerprint/agent',
`jest-preset-angular@${meta.jpa}`,
`jest@${jestVersion}`,
`jest-environment-jsdom@${jestVersion}`,
`@types/jest@${typesJestVersion}`,
'@types/node',
]

const commonOptions = [
'--config.strict-peer-dependencies=false',
'--no-lockfile',
'--config.fund=false',
'--ignore-scripts',
]

await executeCommand(
'pnpm',
['add', ...extraPackagesToInstall, ...extraDevPackagesToInstall, ...commonOptions],
{ cwd: workspaceDir, env: { ...process.env } },
log
)

const libDestDir = path.join(workspaceDir, 'projects', LIB_NAME, 'src', 'lib')
fs.mkdirSync(libDestDir, { recursive: true })
fs.cpSync(path.join(process.cwd(), 'projects', LIB_NAME, 'src', 'lib'), libDestDir, { recursive: true })

fs.copyFileSync(
path.join(process.cwd(), 'projects', LIB_NAME, 'src', 'public-api.ts'),
path.join(workspaceDir, 'projects', LIB_NAME, 'src', 'public-api.ts')
)

const rootFiles = ['jest.config.js', 'tsconfig.json', 'tsconfig.spec.json', 'test.ts']
for (const file of rootFiles) {
const src = path.join(process.cwd(), file)
if (fs.existsSync(src)) {
fs.copyFileSync(src, path.join(workspaceDir, file))
}
}

const projectDir = path.join(workspaceDir, 'projects', LIB_NAME)
const projectFiles = [
'ng-package.json',
'package.json',
'tsconfig.lib.json',
'tsconfig.lib.prod.json',
'tsconfig.spec.json',
]
for (const file of projectFiles) {
fs.copyFileSync(path.join(process.cwd(), 'projects', LIB_NAME, file), path.join(projectDir, file))
}

const tsconfigFiles = [
path.join(workspaceDir, 'tsconfig.json'),
path.join(workspaceDir, 'projects', LIB_NAME, 'tsconfig.spec.json'),
]
for (const file of tsconfigFiles) {
if (fs.existsSync(file)) {
updateJsonFile(file, (json) => {
if (!json.compilerOptions) {
json.compilerOptions = {}
}
json.compilerOptions.skipLibCheck = true
json.compilerOptions.esModuleInterop = true
if (parseInt(version) >= 21) {
json.compilerOptions.moduleResolution = 'bundler'
}
})
}
}

await executeCommand(
'./node_modules/.bin/ng',
['build', LIB_NAME],
{ cwd: workspaceDir, env: { ...process.env } },
log
)

await executeCommand('./node_modules/.bin/jest', [], { cwd: workspaceDir, env: { ...process.env } }, log)

console.log(`Angular ${version}: PASSED`)
return 0
} catch (err: any) {
log(err.stack || err.message)
return 1
} finally {
logStream.end()
fs.rmSync(tempDir, { recursive: true, force: true })
}
}

setupLogDir(LOG_DIR)

const { version: versionsParsed } = parseArgs({
options: {
version: {
type: 'string',
multiple: true,
short: 'v',
},
},
}).values
const versionArgs: string[] = versionsParsed ?? []

const versionsToTest = versionArgs.length > 0 ? versionArgs : Object.keys(angularMetadata)

async function run() {
console.log(`Starting matrix tests for: ${versionsToTest.join(', ')}`)

const results = await Promise.all(versionsToTest.map((version) => testVersion(version)))
const failed = results.some((code) => code !== 0)

if (failed) {
process.exit(1)
} else {
console.log('Success: All versions passed')
process.exit(0)
}
}

run().catch((err) => {
console.error(err)
process.exit(1)
})
16 changes: 16 additions & 0 deletions bin/utils/angularMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface AngularVersionMetadata {
zone: string
jpa: string
jest: string
typesJest?: string
}

export const angularMetadata: Record<string, AngularVersionMetadata> = {
15: { zone: '~0.11.4', jpa: '^13.1.4', jest: '^29.0.0' },
16: { zone: '~0.13.3', jpa: '^13.1.4', jest: '^29.0.0' },
17: { zone: '~0.14.4', jpa: '^14.1.1', jest: '^29.0.0' },
18: { zone: '~0.14.4', jpa: '^14.1.1', jest: '^29.0.0' },
19: { zone: '~0.15.0', jpa: '^14.4.2', jest: '^29.0.0' },
20: { zone: '~0.15.0', jpa: '^15.0.0', jest: '^30.2.0', typesJest: '^30.0.0' },
21: { zone: '~0.16.0', jpa: '^17.0.0', jest: '^30.2.0', typesJest: '^30.0.0' },
}
47 changes: 47 additions & 0 deletions bin/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as fs from 'fs'
import * as path from 'path'
import { spawn, SpawnOptions } from 'child_process'
import { parse, stringify } from 'comment-json'

export function setupLogDir(logDir: string): void {
if (!fs.existsSync(logDir)) {
fs.mkdirSync(logDir, { recursive: true })
} else {
fs.readdirSync(logDir).forEach((file) => {
fs.unlinkSync(path.join(logDir, file))
})
}
}

export function executeCommand(
cmd: string,
args: string[],
opts: SpawnOptions,
log?: (data: string) => void
): Promise<void> {
return new Promise((resolve, reject) => {
const child = spawn(cmd, args, opts)
if (log) {
child.stdout?.on('data', (data) => log(data.toString()))
child.stderr?.on('data', (data) => log(data.toString()))
}
child.on('close', (code) => {
if (code === 0) {
resolve()
} else {
reject(new Error(`Command failed with code ${code}: ${cmd} ${args.join(' ')}`))
}
})
child.on('error', (err) => reject(err))
})
}

export function updateJsonFile(filePath: string, updater: (json: any) => void): void {
if (!fs.existsSync(filePath)) {
return
}
const content = fs.readFileSync(filePath, 'utf8')
const json = parse(content)
updater(json)
fs.writeFileSync(filePath, stringify(json, null, 2), 'utf8')
}
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "fingerprintjs-pro-angular-demo",
"version": "0.0.0",
"engines": {
"node": ">=18.0.0"
},
Comment thread
Copilot marked this conversation as resolved.
"scripts": {
"prepare": "husky install",
"ng": "ng",
Expand All @@ -13,11 +16,12 @@
"build:ssr": "ng build && ng run fingerprintjs-pro-angular-demo:server",
"prerender": "ng run fingerprintjs-pro-angular-demo:prerender",
"generate:version": "node bin/generate-version.js",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 --fix .",
"lint": "eslint --ext .js,.mjs,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "eslint --ext .js,.mjs,.ts --ignore-path .gitignore --max-warnings 0 --fix .",
"test:dts": "tsc -p tsconfig.test-dts.json",
"test": "jest",
"test:coverage": "jest --coverage",
"test:matrix": "pnpm generate:version && tsx bin/test-matrix.ts",
"docs": "typedoc projects/fingerprintjs-pro-angular/src/public-api.ts --out docs",
"changeset:publish": "HUSKY=0 pnpm build && changeset publish",
"changeset:version": "changeset version"
Expand Down Expand Up @@ -55,9 +59,10 @@
"@nguniversal/builders": "^15.2.1",
"@types/express": "^4.17.0",
"@types/jest": "^29.5.12",
"@types/node": "^12.11.1",
"@types/node": "^26.0.1",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"comment-json": "^5.0.0",
"commitizen": "^4.2.5",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.56.0",
Expand All @@ -68,6 +73,7 @@
"lint-staged": "^13.0.3",
"ng-packagr": "^15.2.2",
"prettier": "^3.2.4",
"tsx": "^4.22.4",
"typedoc": "^0.24.8",
"typescript": "~4.9.5"
},
Expand Down
Loading
Loading