Skip to content

Commit

Permalink
chore(typescript): migrate core library to TS
Browse files Browse the repository at this point in the history
Migrates entire library to TS, including support
for TS in the build artifacts. Replaces Sinon with
Jest for testing to resolve ESM import issues in tests.

Author: Evan Jones <evan.a.jones3@gmail.com>
  • Loading branch information
EandrewJones committed May 30, 2024
1 parent ec9b948 commit 1e53be8
Show file tree
Hide file tree
Showing 99 changed files with 15,140 additions and 8,646 deletions.
2 changes: 1 addition & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#

github:
description: "Apache Flagon UserALE.js is a comprehensive, thin-client behavioral logging tool"
description: "Apache Flagon UserALE is a comprehensive, thin-client behavioral logging tool"
homepage: https://flagon.apache.org/
labels:
- flagon
Expand Down
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
"rules" : {
"no-cond-assign" : "warn",
"no-constant-condition" : "warn",
"no-unused-vars" : "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-explicit-any": "warn"
},
"overrides": [
{
"files": ["test/**/*"],
"plugins": ["jest"],
"env": {
"jest": true
}
}
]
}
4 changes: 3 additions & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ jobs:
run: npm ci # clean install

- name: Build
run: npm run build
run: |
export PATH=${PATH}:`go env GOPATH`/bin
npm run build
- name: Test
run: npm run test
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
# specific language governing permissions and limitations
# under the License.
.idea
.vscode
/node_modules/*
/logs/*
/.git/*
npm-debug.log
DS_store
cypress
tsconfig.tsbuildinfo
.rollup.cache
114 changes: 64 additions & 50 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,66 +1,80 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

bash << EOF
sound() {
echo '\a'
}
sound() {
echo '\a'
}

echo "Running pre-commit hooks..."
echo "Running pre-commit hooks..."

# Check Prettier standards
npm run format ||
(
sound
echo "❌ Prettier Check Failed. Run npm run format, add changes and try commit again.";
exit 1;
)
npm run format ||
(
sound
echo "❌ Prettier Check Failed. Run npm run format, add changes and try commit again.";
exit 1;
)

# Check ESLint Standards
npm run lint ||
(
sound
echo "❌ ESLint Check Failed. Make the required changes listed above, add changes and try to commit again."
exit 1;
)
npm run lint ||
(
sound
echo "❌ ESLint Check Failed. Make the required changes listed above, add changes and try to commit again."
exit 1;
)

# TODO: add typescript checks
# Check types
npm run check-types ||
(
sound
echo "❌ Typescript Check Failed. Make the required changes listed above, add changes and try to commit again."
exit 1;
)

# If everything passes... Now we can commit
echo "✅ Checks passed, trying to build..."
echo "✅ Checks passed, trying to build..."

"npm" run build ||
(
sound
echo "❌ Build failed, check errors."
exit 1;
)
"npm" run build ||
(
sound
echo "❌ Build failed, check errors."
exit 1;
)

echo "✅ Successful build, running tests..."
echo "✅ Successful build, running tests..."
# After build, run unit tests
# Right now, runs all tests. Later scope to just unit tets, we can add e2e/integration as github actions on merge
npm run test ||
(
sound
echo "❌ Tests failed: View the logs to see what broke and fix it before re-committing."
exit 1;
)
npm run test ||
(
sound
echo "❌ Tests failed: View the logs to see what broke and fix it before re-committing."
exit 1;
)

# After build, check license headers
# These should be fixed in the postbuild step, but if a new filetype
# emerges, this should catch it.
npm run license:check ||
(
sound
echo "❌ License check failed: View the logs to see what broke and fix it before re-committing."
exit 1;
)

# If everything passes... Now we can commit
echo '✅ All tests passed'
echo '✅ All tests passed'

EOF
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ header:
- '**/*.json'
- '**/*.mjs'
- 'KEYS'
- '**/*.js.map'

comment: on-failure

Expand Down
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Apache Flagon UserALE.js (Incubating) 2.1.1 (2021-02-20)
-------------------------------
* Release Notes - Flagon - Version UserALE.js 2.1.1
* [Closed Tickets](https://github.com/apache/incubator-flagon-useralejs/projects/3)
* Fixes bug in SessionID creation at initial PageLoad
* Fixes bug in sessionId creation at initial PageLoad
* Updates Node.js/NPM Engine support (tested 12.x, 13.x, 14.x, 15.x)
* Minor updates to resolve extant vulnerabilities in dependency tree
* Minor updates to update deprecated downstream dev dependencies
Expand Down Expand Up @@ -116,15 +116,15 @@ Apache Flagon UserALE.js (Incubating) 2.1.0 (2020-02-07)
* [FLAGON-471] - SetRequestHeader should include an Authorization option
* [FLAGON-473] - update packagefile for new version and engines
* [FLAGON-475] - Print Browser Types, Version

Apache Flagon UserALE.js (Incubating) 2.0.2 (2019-08-06)
-------------------------------
* Release Notes - Flagon - Version UserALE.js 2.0.2
* [Release Report](https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12320621&version=12345954)

* Sub-task
* [FLAGON-423] - Update Package File to Fix Down Stream Dependencies

* Bug
* [FLAGON-422] - Update NPM modules to fix prototype pollution issues in npm packages
* [FLAGON-433] - FIx Package.json and Package-Log.json to resolve npm packaging issue
Expand All @@ -135,12 +135,12 @@ Apache Flagon UserALE.js (Incubating) 2.0.2 (2019-08-06)
* Task
* [FLAGON-424] - Update Gulp to 4.0.2 as matter of protocol post Prototype Pollution.
* [FLAGON-425] - Update gulp-eslint
* [FLAGON-426] - update rollup
* [FLAGON-426] - update rollup
* [FLAGON-427] - update nodemon
* [FLAGON-428] - update sinon
* [FLAGON-429] - test userale.js builds and artifacts on npm 6.10
* [FLAGON-430] - update rollup-plugin-license

Apache Flagon UserALE.js (Incubating) 2.0.0 (2019-06-20)
-------------------------------
* Release Notes - Flagon - Version UserALE.js 2.0.0
Expand All @@ -152,18 +152,18 @@ Apache Flagon UserALE.js (Incubating) 2.0.0 (2019-06-20)
* [FLAGON-240] - Update Elasticsearch mapping to accurately parse clientTime variable from userale.js
* [FLAGON-333] - Add pageURL to UserALE.js logs
* [FLAGON-334] - Add pageTitle to UserALE.js
* [FLAGON-337] - Add pageReferrer to UserALE.js
* [FLAGON-337] - Add pageReferrer to UserALE.js

* Bug
* [FLAGON-79] - clientTime is not properly formmated
* [FLAGON-79] - clientTime is not properly formmated
* [FLAGON-167] - Browser plugin CORS permissions
* [FLAGON-169] - Browser Blocking Mixed Content
* [FLAGON-221] - Elasticsearch 5.x does not support microsecond precision
* [FLAGON-321] - Gulp Mocha Dependency Deprecation: Critical Command Injection Vulnerability
* [FLAGON-322] - minimatch deprecation: ReDOS vulnerability
* [FLAGON-323] - Update to Gulp 4.0.0
* [FLAGON-324] - Example Page Does Not Generate Logs
* [FLAGON-338] - Mocha unit tests treat 'document' and 'window' as 'Undefinied' vars
* [FLAGON-338] - Mocha unit tests treat 'document' and 'window' as 'Undefinied' vars
* [FLAGON-340] - UserALE.js fails to build on Branch-336

* New Feature
Expand Down
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache Flagon UserALE.js
Apache Flagon UserALE
Copyright 2024 The Apache Software Foundation

This product includes software developed at The Apache Software Foundation (http://www.apache.org/),
Expand Down
Loading

0 comments on commit 1e53be8

Please sign in to comment.