From eb788bfc708da88a437112c72a35ff7f3f387ea1 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 22 Sep 2022 14:12:44 +0200 Subject: [PATCH 01/13] version bump --- box.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/box.json b/box.json index 06c418a..9239b43 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"MockDataCFC", - "version":"3.6.0", + "version":"3.7.0", "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/MockDataCFC/@build.version@/MockDataCFC-@build.version@.zip", "author":"Ortus Solutions", "homepage":"https://github.com/Ortus-Solutions/MockDataCFC", @@ -28,11 +28,11 @@ ], "dependencies":{}, "devDependencies":{ - "commandbox-cfformat":"*", + "commandbox-cfformat":"*", "commandbox-docbox":"*", "commandbox-dotenv":"*", "commandbox-cfconfig":"*" - }, + }, "installPaths":{}, "ignore":[ "**/.*", @@ -40,11 +40,11 @@ "test-harness", "/server*.json" ], - "testbox":{ + "testbox":{ "runner":"http://localhost:60299/tests/runner.cfm" }, "scripts":{ - "build:module":"task run taskFile=build/Build.cfc :projectName=`package show slug` :version=`package show version`", + "build:module":"task run taskFile=build/Build.cfc :projectName=`package show slug` :version=`package show version`", "build:docs":"task run taskFile=build/Build.cfc target=docs :projectName=`package show slug` :version=`package show version`", "release":"recipe build/release.boxr", "format":"cfformat run handlers,models,test-harness/tests/**.cfc,ModuleConfig.cfc --overwrite", From 09341208640d9d6274d982ce921d99cd03153949 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 22 Sep 2022 15:38:37 +0200 Subject: [PATCH 02/13] location of repo change --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 90cf619..28fd346 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -7,7 +7,7 @@ on: jobs: tests: - uses: coldbox-modules/MockDataCFC/.github/workflows/tests.yml@development + uses: ortus-solutions/MockDataCFC/.github/workflows/tests.yml@development # Format PR format: From f2cd8d0fb45b31fc5944048a896b5b2b18d08afd Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 22 Sep 2022 15:44:44 +0200 Subject: [PATCH 03/13] updated git ignores and extra module template files --- .gitignore | 16 ++++++++++++---- .vscode/settings.json | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index ddc3087..71ae592 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,22 @@ -.vscode - +# Artifacts and temp folders .artifacts/** .tmp/** -test-harness/.engine/** +# Engine + Secrets + databases +.env +.engine/** +test-harness/.engine +.db/** + +# Dependencies test-harness/coldbox/** test-harness/docbox/** test-harness/testbox/** test-harness/logs/** test-harness/modules/** +# modules +modules/** + # log files -logs/** \ No newline at end of file +logs/** diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f20eddc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "cfml.mappings": [ + { + "logicalPath": "/coldbox", + "directoryPath": "./coldbox", + "isPhysicalDirectoryPath" :false + }, + { + "logicalPath": "/testbox", + "directoryPath": "./testbox", + "isPhysicalDirectoryPath" :false + } + ] +} From 3b276ea6fb5f716322e428ccecd6f8b72de5107d Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Fri, 23 Sep 2022 10:25:50 +0200 Subject: [PATCH 04/13] adding debugging and also better docs --- readme.md | 30 +++++++---- test-harness/box.json | 6 ++- test-harness/config/Coldbox.cfc | 90 +++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 31e7b54..7f2670e 100755 --- a/readme.md +++ b/readme.md @@ -60,7 +60,7 @@ http://localhost:3000/?$num=5 # ColdBox Module Service http://localhost:8080/mockdataCFC?$num=5 -# Module API +# object var data = getInstance( "MockData@MockDataCFC" ) .mock( $num = 5 @@ -69,10 +69,10 @@ var data = getInstance( "MockData@MockDataCFC" ) #### Random Numbers -You can also specify a random return number by using the following forms: +You can also specify a random return number by using the `rnd` or `rand` suffix in the following forms: * `$num:rand:10` - A random number between 1-10. -* `$num:rand:5:20` - A random number between 5-20. +* `$num:rnd:5:20` - A random number between 5-20. ```js # service call @@ -88,13 +88,13 @@ var data = getInstance( "MockData@MockDataCFC" ) ); ``` -### Available return types (`$returntype`) +### Available Return Types : (`$returntype`) -By default the service/method call will return X amount of records in the form of an array. However, if you would like to just return an object literal representation you can do so via the `$returnType` argument. +By default the service/method call will return **X** amount of records in the form of an `array`. However, if you would like to just return an object literal representation you can do so by using the `$returnType` argument. Available return types: -* `array` - Default, returns an array of objects +* `array` - **Default**, returns an array of objects * `struct` - Returns an object literal struct ```js @@ -107,9 +107,14 @@ var data = getInstance( "MockData@MockDataCFC" ) id = "uuid", email = "email" ); + // Service call http://127.0.0.1:60299/MockDataCFC?$returnType=struct&name=name&age=age&id=uuid&email=email +``` +The output will be something like this: + +```js // The output will be something like this { "id": "91659091-A489-4706-BAC64FA8E1665509", @@ -184,7 +189,7 @@ Please check out the apidocs at : https://apidocs.ortussolutions.com/#/coldbox-m You can also create your own content by using a supplier closure/lambda as your type. This is a function that will create the content and return it for you. -> Please note that this only works when using the direct function call approach, not the service +> Please note that this only works when using the direct function call approach, not the REST service since you have to pass in a closure. ```js "name" : function( index ){ @@ -192,7 +197,14 @@ You can also create your own content by using a supplier closure/lambda as your } ``` -The function receives the currently iterating `index` as an argument as well. All you need to do is return back content. +The function receives the currently iterating `index` as an argument as well. All you need to do is return back content. Here is another example to return a random item from an array: + +```js +"name" : ( index ) => { + var names = [ "luis", "joe", "jose" ]; + return names[ randRange( 1, names.len() ) ]; +} +``` ### Mocking DSL @@ -321,7 +333,7 @@ getInstance( "MockData@MockDataCFC" ) #### Nested Array of Values -To create nested array of values you will define the name of the property and then an array with a struct defining how many and of which type using the special keys: `$num, $type` +To create nested array of values you will define the `name` of the property and then an array with a struct defining how many and of which type using the special keys: `$num, $type` ```js // array of values diff --git a/test-harness/box.json b/test-harness/box.json index 66df675..3524ff6 100644 --- a/test-harness/box.json +++ b/test-harness/box.json @@ -8,11 +8,13 @@ "coldbox":"*" }, "devDependencies":{ - "testbox":"*" + "testbox":"*", + "cbdebugger":"be" }, "installPaths":{ "coldbox":"coldbox/", - "testbox":"testbox/" + "testbox":"testbox/", + "cbdebugger":"modules/cbdebugger/" }, "testbox":{ "runner":"http://localhost:60299/tests/runner.cfm" diff --git a/test-harness/config/Coldbox.cfc b/test-harness/config/Coldbox.cfc index 3a02869..920b46a 100644 --- a/test-harness/config/Coldbox.cfc +++ b/test-harness/config/Coldbox.cfc @@ -71,6 +71,96 @@ info = [ "coldbox.system" ] }; + moduleSettings = { + cbDebugger = { + // This flag enables/disables the tracking of request data to our storage facilities + // To disable all tracking, turn this master key off + enabled : true, + // This setting controls if you will activate the debugger for visualizations ONLY + // The debugger will still track requests even in non debug mode. + debugMode : true, + // The URL password to use to activate it on demand + debugPassword : "cb:null", + // This flag enables/disables the end of request debugger panel docked to the bottem of the page. + // If you disable i, then the only way to visualize the debugger is via the `/cbdebugger` endpoint + requestPanelDock : true, + // Request Tracker Options + requestTracker : { + // Store the request profilers in heap memory or in cachebox, default is cachebox + storage : "memory", + // Which cache region to store the profilers in + cacheName : "template", + // Track all cbdebugger events, by default this is off, turn on, when actually profiling yourself :) How Meta! + trackDebuggerEvents : false, + // Expand by default the tracker panel or not + expanded : true, + // Slow request threshold in milliseconds, if execution time is above it, we mark those transactions as red + slowExecutionThreshold : 1000, + // How many tracking profilers to keep in stack + maxProfilers : 50, + // If enabled, the debugger will monitor the creation time of CFC objects via WireBox + profileWireBoxObjectCreation : true, + // Profile model objects annotated with the `profile` annotation + profileObjects : false, + // If enabled, will trace the results of any methods that are being profiled + traceObjectResults : false, + // Profile Custom or Core interception points + profileInterceptions : false, + // By default all interception events are excluded, you must include what you want to profile + includedInterceptions : [], + // Control the execution timers + executionTimers : { + expanded : true, + // Slow transaction timers in milliseconds, if execution time of the timer is above it, we mark it + slowTimerThreshold : 250 + }, + // Control the coldbox info reporting + coldboxInfo : { expanded : false }, + // Control the http request reporting + httpRequest : { + expanded : false, + // If enabled, we will profile HTTP Body content, disabled by default as it contains lots of data + profileHTTPBody : false + } + }, + // ColdBox Tracer Appender Messages + tracers : { enabled : true, expanded : false }, + // Request Collections Reporting + collections : { + // Enable tracking + enabled : false, + // Expanded panel or not + expanded : false, + // How many rows to dump for object collections + maxQueryRows : 50, + // How many levels to output on dumps for objects + maxDumpTop : 5 + }, + // CacheBox Reporting + cachebox : { enabled : false, expanded : false }, + // Modules Reporting + modules : { enabled : true, expanded : false }, + // Quick and QB Reporting + qb : { + enabled : false, + expanded : false, + // Log the binding parameters + logParams : true + }, + // cborm Reporting + cborm : { + enabled : false, + expanded : false, + // Log the binding parameters + logParams : true + }, + // Adobe ColdFusion SQL Collector + acfSql : { enabled : false, expanded : false, logParams : true }, + // Async Manager Reporting + async : { enabled : false, expanded : false } + } + } + } /** From 0462ac4482ffd3a3ad3e8326f03e427cda21be3f Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 20 Apr 2023 15:31:14 +0200 Subject: [PATCH 05/13] ### Added - Github actions updates - ColdBox 7 auto testing --- .github/CODE_OF_CONDUCT.MD | 3 + .github/ISSUE_TEMPLATE/BUG_REPORT.md | 33 ++++ .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 18 +++ .github/PULL_REQUEST_TEMPLATE.md | 29 ++++ .github/SECURITY.md | 3 + .github/SUPPORT.md | 3 + .github/workflows/ci.yml | 110 -------------- .github/workflows/gh-release.yml | 27 ---- .github/workflows/pr.yml | 23 +-- .github/workflows/release.yml | 175 ++++++++++++++++++++++ .github/workflows/snapshot.yml | 43 ++++++ .github/workflows/tests.yml | 103 +++++++------ CONTRIBUTING.md | 108 +++++++++++++ box.json | 19 ++- build/Build.cfc | 45 +++--- build/release.boxr | 11 -- changelog.md | 31 +--- server-adobe@2021.json | 3 + server-adobe@2023.json | 29 ++++ test-harness/box.json | 11 +- 20 files changed, 556 insertions(+), 271 deletions(-) create mode 100644 .github/CODE_OF_CONDUCT.MD create mode 100644 .github/ISSUE_TEMPLATE/BUG_REPORT.md create mode 100644 .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/SECURITY.md create mode 100644 .github/SUPPORT.md delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/gh-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/snapshot.yml create mode 100644 CONTRIBUTING.md create mode 100644 server-adobe@2023.json diff --git a/.github/CODE_OF_CONDUCT.MD b/.github/CODE_OF_CONDUCT.MD new file mode 100644 index 0000000..12507ab --- /dev/null +++ b/.github/CODE_OF_CONDUCT.MD @@ -0,0 +1,3 @@ +# Code of Conduct + +Please see it in our [Contributing Guidelines](../CONTRIBUTING.md#code-of-conduct). diff --git a/.github/ISSUE_TEMPLATE/BUG_REPORT.md b/.github/ISSUE_TEMPLATE/BUG_REPORT.md new file mode 100644 index 0000000..300232e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/BUG_REPORT.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +--- + + + +## What are the steps to reproduce this issue? + +1. … +2. … +3. … + +## What happens? + +… + +## What were you expecting to happen? + +… + +## Any logs, error output, etc? + +… + +## Any other comments? + +… + +## What versions are you using? + +**Operating System:** … +**Package Version:** … diff --git a/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md new file mode 100644 index 0000000..c10946f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: Request a new feature or enhancement +--- + + + +## Summary + + + +## Detailed Description + + + +## Possible Implementation Ideas + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e8bd9f9 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,29 @@ +# Description + +Please include a summary of the changes and which issue(s) is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. + +**Please note that all PRs must have tests attached to them** + +IMPORTANT: Please review the [CONTRIBUTING.md](../CONTRIBUTING.md) file for detailed contributing guidelines. + +## Issues + +All PRs must have an accompanied issue. Please make sure you created it and linked it here. + +## Type of change + +Please delete options that are not relevant. + +- [ ] Bug Fix +- [ ] Improvement +- [ ] New Feature +- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] This change requires a documentation update + +## Checklist + +- [ ] My code follows the style guidelines of this project [cfformat](../.cfformat.json) +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..f057099 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,3 @@ +# Security Policy + +Please see it in our [Contributing Guidelines](../CONTRIBUTING.md#security-vulnerabilities). diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md new file mode 100644 index 0000000..3bb8adb --- /dev/null +++ b/.github/SUPPORT.md @@ -0,0 +1,3 @@ +# Support & Help + +Please see it in our [Contributing Guidelines](../CONTRIBUTING.md#support-questions). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index efb5140..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,110 +0,0 @@ -name: MockDataCFC CI - -# Only on Development we build snapshots -on: - push: - branches: - - development - - master - -env: - MODULE_ID: MockDataCFC - -jobs: - ############################################# - # Tests First baby! We fail, no build :( - ############################################# - tests: - uses: ./.github/workflows/tests.yml - secrets: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - ############################################# - # Build Module - ############################################# - build: - name: Build & Publish - needs: tests - runs-on: ubuntu-20.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: "adopt" - java-version: "11" - - - name: Setup CommandBox - uses: Ortus-Solutions/setup-commandbox@main - with: - forgeboxAPIKey: ${{ secrets.FORGEBOX_API_TOKEN }} - - - name: Setup Environment Variables For Build Process - id: current_version - run: | - echo "VERSION=`cat box.json | jq '.version' -r`" >> $GITHUB_ENV - box package set version=@build.version@+@build.number@ - # master or snapshot - echo "Github Ref is $GITHUB_REF" - echo "BRANCH=master" >> $GITHUB_ENV - if [ $GITHUB_REF == 'refs/heads/development' ] - then - echo "BRANCH=development" >> $GITHUB_ENV - fi - - - name: Build ${{ env.MODULE_ID }} - run: | - box install commandbox-docbox - box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} - - - name: Upload Build Artifacts - if: success() - uses: actions/upload-artifact@v2 - with: - name: ${{ env.MODULE_ID }} - path: | - .artifacts/**/* - - - name: Upload Binaries to S3 - uses: jakejarvis/s3-sync-action@master - with: - args: --acl public-read - env: - AWS_S3_BUCKET: "downloads.ortussolutions.com" - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} - SOURCE_DIR: ".artifacts/${{ env.MODULE_ID }}" - DEST_DIR: "ortussolutions/coldbox-modules/${{ env.MODULE_ID }}" - - - name: Upload API Docs to S3 - uses: jakejarvis/s3-sync-action@master - with: - args: --acl public-read - env: - AWS_S3_BUCKET: "apidocs.ortussolutions.com" - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} - SOURCE_DIR: ".tmp/apidocs" - DEST_DIR: "coldbox-modules/${{ env.MODULE_ID }}/${{ env.VERSION }}" - - - name: Publish To ForgeBox - run: | - cd .tmp/${{ env.MODULE_ID }} - cat box.json - box forgebox publish - - - name: Inform Slack - if: ${{ always() }} - uses: rtCamp/action-slack-notify@v2 - env: - SLACK_CHANNEL: coding - SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' - SLACK_ICON_EMOJI: ":bell:" - SLACK_MESSAGE: '${{ env.MODULE_ID }} Built with ${{ job.status }}!' - SLACK_TITLE: "${{ env.MODULE_ID }} Build" - SLACK_USERNAME: CI - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml deleted file mode 100644 index 90cf619..0000000 --- a/.github/workflows/gh-release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Pull Requests - -on: - pull_request: - branches: - - development - -jobs: - tests: - uses: coldbox-modules/MockDataCFC/.github/workflows/tests.yml@development - - # Format PR - format: - name: Format - runs-on: ubuntu-20.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - uses: Ortus-Solutions/commandbox-action@v1.0.2 - with: - cmd: run-script format - - - name: Commit Format Changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Apply cfformat changes diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 28fd346..7018845 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,27 +1,28 @@ name: Pull Requests on: + push: + branches-ignore: + - "main" + - "master" + - "development" + - "releases/v*" pull_request: branches: + - "releases/v*" - development jobs: tests: - uses: ortus-solutions/MockDataCFC/.github/workflows/tests.yml@development + uses: ./.github/workflows/tests.yml - # Format PR - format: - name: Format + formatCheck: + name: Checks Source Code Formatting runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: - cmd: run-script format - - - name: Commit Format Changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Apply cfformat changes + cmd: run-script format:check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7a1d896 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,175 @@ +name: Build a Release + +on: + # If you push to master|main this will trigger a stable release + push: + branches: + - master + - main + + # Reusable workflow : Usually called by a `snapshot` workflow + workflow_call: + inputs: + snapshot: + description: 'Is this a snapshot build?' + required: false + default: false + type: boolean + +env: + MODULE_ID: MockDataCFC + SNAPSHOT: ${{ inputs.snapshot || false }} + +jobs: + ########################################################################################## + # Build & Publish + ########################################################################################## + build: + name: Build & Publish + runs-on: ubuntu-20.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup CommandBox + uses: Ortus-Solutions/setup-commandbox@v2.0.1 + with: + forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }} + + - name: "Setup Environment Variables For Build Process" + id: current_version + run: | + echo "VERSION=`cat box.json | jq '.version' -r`" >> $GITHUB_ENV + box package set version=@build.version@+@build.number@ + # master or snapshot + echo "Github Ref is $GITHUB_REF" + echo "BRANCH=master" >> $GITHUB_ENV + if [ $GITHUB_REF == 'refs/heads/development' ] + then + echo "BRANCH=development" >> $GITHUB_ENV + fi + + - name: Update changelog [unreleased] with latest version + uses: thomaseizinger/keep-a-changelog-new-release@1.3.0 + if: env.SNAPSHOT == 'false' + with: + changelogPath: ./changelog.md + tag: v${{ env.VERSION }} + + - name: Build ${{ env.MODULE_ID }} + run: | + npm install -g markdownlint-cli + markdownlint changelog.md --fix + box install commandbox-docbox + box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} + + - name: Commit Changelog To Master + uses: EndBug/add-and-commit@v9.1.1 + if: env.SNAPSHOT == 'false' + with: + author_name: Github Actions + author_email: info@ortussolutions.com + message: 'Finalized changelog for v${{ env.VERSION }}' + add: changelog.md + + - name: Tag Version + uses: rickstaa/action-create-tag@v1.6.1 + if: env.SNAPSHOT == 'false' + with: + tag: "v${{ env.VERSION }}" + force_push_tag: true + message: "Latest Release v${{ env.VERSION }}" + + - name: Upload Build Artifacts + if: success() + uses: actions/upload-artifact@v3 + with: + name: ${{ env.MODULE_ID }} + path: | + .artifacts/**/* + changelog.md + + - name: Upload Binaries to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read + env: + AWS_S3_BUCKET: "downloads.ortussolutions.com" + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} + SOURCE_DIR: ".artifacts/${{ env.MODULE_ID }}" + DEST_DIR: "ortussolutions/coldbox-modules/${{ env.MODULE_ID }}" + + - name: Upload API Docs to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read + env: + AWS_S3_BUCKET: "apidocs.ortussolutions.com" + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACCESS_SECRET }} + SOURCE_DIR: ".tmp/apidocs" + DEST_DIR: "coldbox-modules/${{ env.MODULE_ID }}/${{ env.VERSION }}" + + - name: Publish To ForgeBox + run: | + cd .tmp/${{ env.MODULE_ID }} + cat box.json + box forgebox publish --force + + - name: Create Github Release + uses: taiki-e/create-gh-release-action@v1.6.2 + continue-on-error: true + if: env.SNAPSHOT == 'false' + with: + title: ${{ env.VERSION }} + changelog: changelog.md + token: ${{ secrets.GITHUB_TOKEN }} + ref: refs/tags/v${{ env.VERSION }} + + ########################################################################################## + # Prep Next Release + ########################################################################################## + prep_next_release: + name: Prep Next Release + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' + runs-on: ubuntu-20.04 + needs: [ build ] + steps: + # Checkout development + - name: Checkout Repository + uses: actions/checkout@v3 + with: + ref: development + + - name: Setup CommandBox + uses: Ortus-Solutions/setup-commandbox@v2.0.1 + with: + forgeboxAPIKey: ${{ secrets.FORGEBOX_TOKEN }} + + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: ${{ env.MODULE_ID }} + path: .tmp + + # Copy the changelog to the development branch + - name: Copy Changelog + run: | + cp .tmp/changelog.md changelog.md + + # Bump to next version + - name: Bump Version + run: | + box bump --minor --!TagVersion + + # Commit it back to development + - name: Commit Version Bump + uses: EndBug/add-and-commit@v9.1.1 + with: + author_name: Github Actions + author_email: info@ortussolutions.com + message: 'Version bump' + add: | + box.json + changelog.md diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..45d7dd1 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,43 @@ +name: Build Snapshot + +on: + push: + branches: + - 'development' + +jobs: + ########################################################################################## + # Module Tests + ########################################################################################## + tests: + secrets: inherit + uses: ./.github/workflows/tests.yml + + ########################################################################################## + # Format Source Code + ########################################################################################## + format: + name: Code Auto-Formatting + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + + - name: Auto-format + uses: Ortus-Solutions/commandbox-action@v1.0.2 + with: + cmd: run-script format + + - name: Commit Format Changes + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Apply cfformat changes + + ########################################################################################## + # Release it + ########################################################################################## + release: + uses: ./.github/workflows/release.yml + needs: [ tests, format ] + secrets: inherit + with: + snapshot: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d8b29d2..2d10f11 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,7 +5,7 @@ on: workflow_call: secrets: SLACK_WEBHOOK_URL: - required: true + required: false jobs: tests: @@ -14,91 +14,104 @@ jobs: env: DB_USER: root DB_PASSWORD: root + continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false matrix: cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ] + coldboxVersion: [ "^6.0.0" ] + experimental: [ false ] + include: + - cfengine: "adobe@2023" + coldboxVersion: "^6.0.0" + experimental: true + - coldboxVersion: "be" + cfengine: "lucee@5" + experimental: true + - coldboxVersion: "be" + cfengine: "adobe@2018" + experimental: true + - coldboxVersion: "be" + cfengine: "adobe@2021" + experimental: true steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + # Not Needed in this module + #- name: Setup Database and Fixtures + # run: | + # sudo /etc/init.d/mysql start + # mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' + # mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: - distribution: "adopt" + distribution: "temurin" java-version: "11" - - name: Setup Database and Fixtures - run: | - #sudo systemctl start mysql.service - # Create Database - #mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} -e 'CREATE DATABASE coolblog;' - # Import Database - #mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < test-harness/tests/resources/coolblog.sql - - - name: Setup Environment For Testing Process - run: | - # Setup .env - touch .env - # ENV - printf "ENVIRONMENT=development\n" >> .env - printf "DB_HOST=localhost\n" >> .env - printf "DB_USER=${{ env.DB_USER }}\n" >> .env - printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env - printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env - printf "DB_BUNDLEVERSION=8.0.19\n" >> .env - printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env - - name: Setup CommandBox CLI - uses: Ortus-Solutions/setup-commandbox@main - with: - version: 5.4.2 + uses: Ortus-Solutions/setup-commandbox@v2.0.1 - - name: Install Dependencies + # Not Needed in this module + #- name: Setup Environment For Testing Process + # working-directory: ./test-harness + # run: | + # # Setup .env + # touch .env + # # ENV + # printf "DB_HOST=localhost\n" >> .env + # printf "DB_DATABASE=mydatabase\n" >> .env + # printf "DB_DRIVER=MySQL\n" >> .env + # printf "DB_USER=${{ env.DB_USER }}\n" >> .env + # printf "DB_PASSWORD=${{ env.DB_PASSWORD }}\n" >> .env + # printf "DB_CLASS=com.mysql.cj.jdbc.Driver\n" >> .env + # printf "DB_BUNDLEVERSION=8.0.19\n" >> .env + # printf "DB_BUNDLENAME=com.mysql.cj\n" >> .env + + - name: Install Test Harness with ColdBox ${{ matrix.coldboxVersion }} run: | box install - cd test-harness && box install + cd test-harness + box package set dependencies.coldbox=${{ matrix.coldboxVersion }} + box install - name: Start ${{ matrix.cfengine }} Server run: | box server start serverConfigFile="server-${{ matrix.cfengine }}.json" --noSaveSettings --debug - # Install Adobe 2021 cfpm modules - if [[ "${{ matrix.cfengine }}" == "adobe@2021" ]] ; then - box run-script install:2021 - fi curl http://127.0.0.1:60299 - name: Run Tests run: | mkdir -p test-harness/tests/results box testbox run --verbose outputFile=test-harness/tests/results/test-results outputFormats=json,antjunit - ls -lR test-harness/tests - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - files: test-harness/tests/results/**/*.xml - check_name: "${{ matrix.cfengine }} Test Results" + junit_files: test-harness/tests/results/**/*.xml + check_name: "${{ matrix.cfengine }} ColdBox ${{ matrix.coldboxVersion }} Test Results" - name: Upload Test Results to Artifacts if: always() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: test-results-${{ matrix.cfengine }} + name: test-results-${{ matrix.cfengine }}-${{ matrix.coldboxVersion }} path: | test-harness/tests/results/**/* - - name: Failure Debugging Log + - name: Show Server Log On Failures if: ${{ failure() }} run: | box server log serverConfigFile="server-${{ matrix.cfengine }}.json" - - name: Upload Debugging Log To Artifacts + - name: Upload Debug Logs To Artifacts if: ${{ failure() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: Failure Debugging Info - ${{ matrix.cfengine }} + name: Failure Debugging Info - ${{ matrix.cfengine }} - ${{ matrix.coldboxVersion }} path: | .engine/**/logs/* .engine/**/WEB-INF/cfusion/logs/* @@ -112,6 +125,6 @@ jobs: SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' SLACK_ICON_EMOJI: ":bell:" SLACK_MESSAGE: '${{ github.repository }} tests failed :cry:' - SLACK_TITLE: ${{ github.repository }} Tests For ${{ matrix.cfengine }} failed + SLACK_TITLE: ${{ github.repository }} Tests For ${{ matrix.cfengine }} with ColdBox ${{ matrix.coldboxVersion }} failed SLACK_USERNAME: CI SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..a6f7faf --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,108 @@ +# Contributing Guide + +Hola amigo! I'm really excited that you are interested in contributing to mockdatacfc. Before submitting your contribution, please make sure to take a moment and read through the following guidelines: + +- [Code Of Conduct](#code-of-conduct) +- [Bug Reporting](#bug-reporting) +- [Support Questions](#support-questions) +- [Pull Request Guidelines](#pull-request-guidelines) +- [Security Vulnerabilities](#security-vulnerabilities) +- [Development Setup](#development-setup) +- [Language Compatibility](#language-compatibility) +- [Coding Styles \& Formatting](#coding-styles--formatting) +- [CFC Docs With DocBox](#cfc-docs-with-docbox) +- [Financial Contributions](#financial-contributions) +- [Contributors](#contributors) + +## Code Of Conduct + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code held within. They make the code freely available in the hope that it will be of use to other developers and/or businesses. Please be considerate towards maintainers when raising issues or presenting pull requests. **We all follow the Golden Rule: Do to others as you want them to do to you.** + +- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. +- Participants will be tolerant of opposing views. +- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. +- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. +- When interpreting the words and actions of others, participants should always assume good intentions. Emotions cannot be derived from textual representations. +- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. + + +## Bug Reporting + +Please make sure also that if you submit a pull request, you link it to the appropriate issue(s). + +If you file a bug report, your issue should contain a title, a clear description of the issue, a way to replicate the issue, and any support files that we might need to replicate your issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix for it. All issues that do not contain a way to replicate will not be addressed. + +## Support Questions + +If you have any questions on usage, professional support or just ideas to bounce off the maintainers, please do not create an issue. Leverage our support channels first. + +- Ortus Community Discourse: https://community.ortussolutions.com +- Box Slack Team: http://boxteam.ortussolutions.com/ +- Professional Support: https://www.ortussolutions.com/services/support + +## Pull Request Guidelines + +- The `(master|main)` branch is just a snapshot of the latest stable release. All development should be done in dedicated branches. Do not submit PRs against the master branch. They will be closed. +- All pull requests should be sent to the `development` branch or the appropriate LTS branch (`releases/v{version}`). +- It's OK to have multiple small commits as you work on the PR - GitHub will automatically squash it before merging. +- Make sure all local tests pass before submitting the merge. +- Please make sure all your pull requests have companion tests. +- Please link the Jira issue in your PR title when sending the final PR + +## Security Vulnerabilities + +If you discover a security vulnerability, please send an email to the Ortus security team at [security@ortussolutions.com](mailto:security@ortussolutions.com?subject=security) and make sure you report it to the `#security` channel in our Box Team Slack Channel. All security vulnerabilities will be promptly addressed. + +## Development Setup + +1. Fork and Star our project. +2. Make sure you have CommandBox installed: https://www.ortussolutions.com/products/commandbox#download +3. Start a CommandBox shell in the root of the project: `box` +4. Install the development dependencies: `run-script install:dependencies` +5. Hack away! Create tests under `/test-harness/specs` or wherever they are set in the project and run the tests! + +## Language Compatibility + +Please make sure your code runs on the following CFML Engines: + +- Lucee 5+ +- Adobe ColdFusion 2018+ + +## Coding Styles & Formatting + +We are big on coding styles and have included a `.cfformat.json` in the root of the project so that you can run the formatting tools and CommandBox scripts: + +```bash +# Format everything +box run-script format + +# Start a watcher, type away, save and auto-format for you +box run-script format:watch +``` + +We recommend that anytime you hack on the core you start the formatter watcher (`box run-script format:watch`). This will monitor your changes and auto-format your code for you. + +You can also see the Ortus Coding Standards you must follow here: https://github.com/Ortus-Solutions/coding-standards. + +## CFC Docs With DocBox + +All CFCs are self-documenting and we leverage [DocBox](https://docbox.ortusbooks.com/) to document the entire software. All functions must be properly documented using the DocBox syntax: https://docbox.ortusbooks.com/getting-started/annotating-your-code + + +## Financial Contributions + +You can support ColdBox and all of our Open Source initiatives at Ortus Solutions by becoming a patreon. You can also get lots of goodies and services depending on the level of contributions. + +- [Become a backer or sponsor on Patreon](https://www.patreon.com/ortussolutions) +- [One-time donations via PayPal](https://www.paypal.com/paypalme/ortussolutions) + +## Contributors + +Thank you to all the people who have already contributed to mockdatacfc! We :heart: :heart: :heart: love you! + + + + + + +Made with [contributors-img](https://contrib.rocks) diff --git a/box.json b/box.json index 9239b43..d85f6b4 100644 --- a/box.json +++ b/box.json @@ -47,12 +47,17 @@ "build:module":"task run taskFile=build/Build.cfc :projectName=`package show slug` :version=`package show version`", "build:docs":"task run taskFile=build/Build.cfc target=docs :projectName=`package show slug` :version=`package show version`", "release":"recipe build/release.boxr", - "format":"cfformat run handlers,models,test-harness/tests/**.cfc,ModuleConfig.cfc --overwrite", - "format:watch":"cfformat watch handlers,models,test-harness/tests/**.cfc,ModuleConfig.cfc ./.cfformat.json", - "format:check":"cfformat check handlers,models,test-harness/tests/**.cfc,ModuleConfig.cfc", - "cfpm":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\"' | run", - "cfpm:install":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\" install ${1}' | run", - "install:2021":"run-script cfpm:install zip,debugger,orm,mysql,postgresql,sqlserver,feed,chart", - "install:dependencies":"install && cd test-harness && install" + "format":"cfformat run helpers,models,test-harness/tests/,ModuleConfig.cfc --overwrite", + "format:watch":"cfformat watch helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json", + "format:check":"cfformat check helpers,models,test-harness/tests/,ModuleConfig.cfc ./.cfformat.json", + "start:lucee" : "server start serverConfigFile=server-lucee@5.json", + "start:2018" : "server start serverConfigFile=server-adobe@2018.json", + "start:2021" : "server start serverConfigFile=server-adobe@2021.json", + "stop:lucee" : "server stop serverConfigFile=server-lucee@5.json", + "stop:2018" : "server stop serverConfigFile=server-adobe@2018.json", + "stop:2021" : "server stop serverConfigFile=server-adobe@2021.json", + "logs:lucee" : "server log serverConfigFile=server-lucee@5.json --follow", + "logs:2018" : "server log serverConfigFile=server-adobe@2018.json --follow", + "logs:2021" : "server log serverConfigFile=server-adobe@2021.json --follow" } } diff --git a/build/Build.cfc b/build/Build.cfc index 926cce1..ee9366e 100644 --- a/build/Build.cfc +++ b/build/Build.cfc @@ -76,9 +76,6 @@ component { // checksums buildChecksums(); - // Build latest changelog - latestChangelog(); - // Finalize Message print .line() @@ -130,9 +127,7 @@ component { ) .toConsole(); - // Prepare exports directory - variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#"; - directoryCreate( variables.exportsDir, true, true ); + ensureExportDir( argumentCollection = arguments ); // Project Build Dir variables.projectBuildDir = variables.buildDir & "/#projectName#"; @@ -200,11 +195,12 @@ component { version = "1.0.0", outputDir = ".tmp/apidocs" ){ + ensureExportDir( argumentCollection = arguments ); + // Create project mapping fileSystemUtil.createMapping( arguments.projectName, variables.cwd ); // Generate Docs print.greenLine( "Generating API Docs, please wait..." ).toConsole(); - directoryCreate( arguments.outputDir, true, true ); command( "docbox generate" ) .params( @@ -228,27 +224,6 @@ component { ); } - /** - * Build the latest changelog file: changelog-latest.md - */ - function latestChangelog(){ - print.blueLine( "Building latest changelog..." ).toConsole(); - - if ( !fileExists( variables.cwd & "changelog.md" ) ) { - return error( "Cannot continue building, changelog.md file doesn't exist!" ); - } - - fileWrite( - variables.cwd & "changelog-latest.md", - fileRead( variables.cwd & "changelog.md" ).split( "----" )[ 2 ].trim() & chr( 13 ) & chr( 10 ) - ); - - print - .greenLine( "Latest changelog file created at `changelog-latest.md`" ) - .line() - .line( fileRead( variables.cwd & "changelog-latest.md" ) ); - } - /********************************************* PRIVATE HELPERS *********************************************/ /** @@ -315,4 +290,18 @@ component { return ( createObject( "java", "java.lang.System" ).getProperty( "cfml.cli.exitCode" ) ?: 0 ); } + /** + * Ensure the export directory exists at artifacts/NAME/VERSION/ + */ + private function ensureExportDir( + required projectName, + version = "1.0.0" + ){ + if ( structKeyExists( variables, "exportsDir" ) && directoryExists( variables.exportsDir ) ){ + return; + } + // Prepare exports directory + variables.exportsDir = variables.artifactsDir & "/#projectName#/#arguments.version#"; + directoryCreate( variables.exportsDir, true, true ); + } } diff --git a/build/release.boxr b/build/release.boxr index e216f22..a63f2cc 100755 --- a/build/release.boxr +++ b/build/release.boxr @@ -7,19 +7,8 @@ # Merge development into it for release !git merge --no-ff development -# Tag the master repo with the version from box.json -!git tag v`box package show version` - # Push all branches back out to github !git push origin --all -# Push all tags -!git push origin --tags - # Check development again !git checkout -f development - -# Bump to prepare for a new release, do minor, change if needed and don't tag -bump --minor --!tagVersion -!git commit -a -m "version bump" -!git push origin development \ No newline at end of file diff --git a/changelog.md b/changelog.md index e422970..27b288f 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ---- +## [Unreleased] + +### Added + +- Github actions updates +- ColdBox 7 auto testing + ## [3.6.0] => 2022-SEP-22 ### Added @@ -17,8 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * DateRanges ----- - ## [3.5.0] => 2022-JAN-11 ### Added @@ -27,8 +32,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Formatting and code quality rules * `guid` generator thanks to @djcard ----- - ## [3.4.0] => 2020-JUN-03 ### Added @@ -54,16 +57,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Access variables according to scopes * `$returnType` is not documented #8 ----- - ## [3.3.1] => 2020-APR-16 ### Fixed * param the default method when executing via URL instead of setting it. ----- - ## [3.3.0] => 2020-JAN-28 ### New Features @@ -85,8 +84,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added new domains for more random generation * Removed spacing from words ----- - ## [3.2.0] => 2020-JAN-08 ### New Features @@ -101,15 +98,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * TestBox 3 upgrade * More direct scoping of the arguments scope ----- - ## [3.1.0] => 2019-MAY-19 * CommandBox ability to execute * Template updates to standards ----- - ## [3.0.0] => 2018-SEP-4 * **Compatibility** : `num` arguments have been dropped and you must use `$num` as the identifier for how many items you like @@ -138,14 +131,10 @@ This will produce top level mock data with 2 books per record. * Updated readmes and syntax updates for modern engines * Upgraded to new ColdBox module Harness ----- - ## [2.4.0] * Added auto-incrementing ID's FOR REAL this time ----- - ## [2.3.0] * Added auto-incrementing ID's @@ -156,14 +145,10 @@ This will produce top level mock data with 2 books per record. * Bug on `isDefault()` always returning true. * Added tests and automation ----- - ## [2.2.0] * Made it a module as well for ColdBox apps. ----- - ## [2.0.0] * Added support for words, sentences, uuid, bacon lorem, date and datetime @@ -171,8 +156,6 @@ This will produce top level mock data with 2 books per record. * Added Documentation * Added ability to execute as a CFC instead of only via web service ----- - ## [1.0.0] Original by Ray Camden diff --git a/server-adobe@2021.json b/server-adobe@2021.json index 580a3a9..f91ba10 100644 --- a/server-adobe@2021.json +++ b/server-adobe@2021.json @@ -19,5 +19,8 @@ "openBrowser":"false", "cfconfig":{ "file":".cfconfig.json" + }, + "scripts" : { + "onServerInstall":"cfpm install zip,debugger" } } diff --git a/server-adobe@2023.json b/server-adobe@2023.json new file mode 100644 index 0000000..a881217 --- /dev/null +++ b/server-adobe@2023.json @@ -0,0 +1,29 @@ +{ + "name":"route-visualizer-adobe@2023", + "app":{ + "serverHomeDirectory":".engine/adobe2023", + "cfengine":"adobe@2023.0.0-beta.1" + }, + "web":{ + "http":{ + "port":"60299" + }, + "rewrites":{ + "enable":"true" + }, + "webroot": "test-harness", + "aliases":{ + "/moduleroot/route-visualizer":"../" + } + }, + "jvm":{ + "heapSize":"1024" + }, + "openBrowser":"false", + "cfconfig": { + "file" : ".cfconfig.json" + }, + "scripts" : { + "onServerInstall":"cfpm install zip,debugger" + } +} diff --git a/test-harness/box.json b/test-harness/box.json index 3524ff6..fe4e7ed 100644 --- a/test-harness/box.json +++ b/test-harness/box.json @@ -5,23 +5,18 @@ "private":true, "description":"", "dependencies":{ - "coldbox":"*" + "coldbox":"^6.0.0" }, "devDependencies":{ - "testbox":"*", - "cbdebugger":"be" + "testbox":"*" }, "installPaths":{ "coldbox":"coldbox/", - "testbox":"testbox/", - "cbdebugger":"modules/cbdebugger/" + "testbox":"testbox/" }, "testbox":{ "runner":"http://localhost:60299/tests/runner.cfm" }, "scripts":{ - "cfpm":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\"' | run", - "cfpm:install":"echo '\".engine/adobe2021/WEB-INF/cfusion/bin/cfpm.sh\" install ${1}' | run", - "install:2021":"run-script cfpm:install zip,debugger" } } From 47220b3f57b9deb5097c3554db293cec907769d4 Mon Sep 17 00:00:00 2001 From: lmajano Date: Thu, 20 Apr 2023 13:32:00 +0000 Subject: [PATCH 06/13] Apply cfformat changes --- models/MockData.cfc | 6 ++++- test-harness/tests/Application.cfc | 38 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/models/MockData.cfc b/models/MockData.cfc index 019b38f..68944dd 100644 --- a/models/MockData.cfc +++ b/models/MockData.cfc @@ -703,7 +703,11 @@ component { timeFormat = "medium" ){ var timeDifference = dateDiff( "s", arguments.from, arguments.to ); - var result = dateAdd( "s", randRange( 0, timeDifference ), arguments.from ); + var result = dateAdd( + "s", + randRange( 0, timeDifference ), + arguments.from + ); if ( arguments.showTime ) { return dateFormat( result, arguments.dateFormat ) & " " & timeFormat( result, arguments.timeFormat ); diff --git a/test-harness/tests/Application.cfc b/test-harness/tests/Application.cfc index 7bbdc6a..64bdaac 100644 --- a/test-harness/tests/Application.cfc +++ b/test-harness/tests/Application.cfc @@ -1,7 +1,7 @@ /** -* ******************************************************************************* -* ******************************************************************************* -*/ + * ******************************************************************************* + * ******************************************************************************* + */ component { // UPDATE THE NAME OF THE MODULE IN TESTING BELOW @@ -9,14 +9,14 @@ component { request.MODULE_PATH = "MockDataCFC"; // APPLICATION CFC PROPERTIES - this.name = "ColdBoxTestingSuite"; - this.sessionManagement = true; - this.setClientCookies = true; - this.sessionTimeout = createTimeSpan( 0, 0, 15, 0 ); - this.applicationTimeout = createTimeSpan( 0, 0, 15, 0 ); + this.name = "ColdBoxTestingSuite"; + this.sessionManagement = true; + this.setClientCookies = true; + this.sessionTimeout = createTimespan( 0, 0, 15, 0 ); + this.applicationTimeout = createTimespan( 0, 0, 15, 0 ); // Turn on/off white space management this.whiteSpaceManagement = "smart"; - this.enableNullSupport = shouldEnableFullNullSupport(); + this.enableNullSupport = shouldEnableFullNullSupport(); // Create testing mapping this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() ); @@ -37,9 +37,9 @@ component { public boolean function onRequestStart( targetPage ){ // Set a high timeout for long running tests - setting requestTimeout="9999"; + setting requestTimeout ="9999"; // New ColdBox Virtual Application Starter - request.coldBoxVirtualApp = new coldbox.system.testing.VirtualApp( appMapping = "/root" ); + request.coldBoxVirtualApp= new coldbox.system.testing.VirtualApp( appMapping = "/root" ); // If hitting the runner or specs, prep our virtual app if ( getBaseTemplatePath().replace( expandPath( "/tests" ), "" ).reFindNoCase( "(runner|specs)" ) ) { @@ -47,8 +47,8 @@ component { } // ORM Reload for fresh results - if( structKeyExists( url, "fwreinit" ) ){ - if( structKeyExists( server, "lucee" ) ){ + if ( structKeyExists( url, "fwreinit" ) ) { + if ( structKeyExists( server, "lucee" ) ) { pagePoolClear(); } // ormReload(); @@ -58,14 +58,14 @@ component { return true; } - public void function onRequestEnd( required targetPage ) { + public void function onRequestEnd( required targetPage ){ request.coldBoxVirtualApp.shutdown(); } - private boolean function shouldEnableFullNullSupport() { - var system = createObject( "java", "java.lang.System" ); - var value = system.getEnv( "FULL_NULL" ); - return isNull( value ) ? false : !!value; - } + private boolean function shouldEnableFullNullSupport(){ + var system = createObject( "java", "java.lang.System" ); + var value = system.getEnv( "FULL_NULL" ); + return isNull( value ) ? false : !!value; + } } From 17ff9ab2bcfc7012acac3ea3f56c6d14dc2231dd Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 20 Apr 2023 15:33:27 +0200 Subject: [PATCH 07/13] fixing paths --- server-adobe@2023.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server-adobe@2023.json b/server-adobe@2023.json index a881217..86bcb69 100644 --- a/server-adobe@2023.json +++ b/server-adobe@2023.json @@ -1,5 +1,5 @@ { - "name":"route-visualizer-adobe@2023", + "name":"MockDataCFC-adobe@2023", "app":{ "serverHomeDirectory":".engine/adobe2023", "cfengine":"adobe@2023.0.0-beta.1" @@ -13,7 +13,7 @@ }, "webroot": "test-harness", "aliases":{ - "/moduleroot/route-visualizer":"../" + "/moduleroot/MockDataCFC":"../" } }, "jvm":{ From 443765490a3022b747a15eb4510db2b195def2b2 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 20 Apr 2023 15:43:19 +0200 Subject: [PATCH 08/13] repo location --- .vscode/tasks.json | 33 +++++++++++++++++++++++++++++++++ box.json | 10 +++++----- readme.md | 2 +- 3 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..6092c9d --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run CommandBox Task", + "type": "shell", + "command": "box task run ${relativeFile}", + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + }, + { + "label": "Run TestBox Bundle", + "type": "shell", + "command": "box testbox run bundles=${relativeFile} --!recurse", + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "new" + }, + "problemMatcher": [] + } + ] +} diff --git a/box.json b/box.json index d85f6b4..5a25f07 100644 --- a/box.json +++ b/box.json @@ -3,19 +3,19 @@ "version":"3.7.0", "location":"https://downloads.ortussolutions.com/ortussolutions/coldbox-modules/MockDataCFC/@build.version@/MockDataCFC-@build.version@.zip", "author":"Ortus Solutions", - "homepage":"https://github.com/Ortus-Solutions/MockDataCFC", - "documentation":"https://github.com/Ortus-Solutions/MockDataCFC", + "homepage":"https://github.com/coldbox-modules/MockDataCFC", + "documentation":"https://github.com/coldbox-modules/MockDataCFC", "repository":{ "type":"git", - "URL":"https://github.com/Ortus-Solutions/MockDataCFC" + "URL":"https://github.com/coldbox-modules/MockDataCFC" }, "license":[ { "type":"MIT", - "URL":"https://github.com/Ortus-Solutions/MockDataCFC/LICENSE" + "URL":"https://github.com/coldbox-modules/MockDataCFC/LICENSE" } ], - "bugs":"https://github.com/Ortus-Solutions/MockDataCFC/issues", + "bugs":"https://github.com/coldbox-modules/MockDataCFC/issues", "slug":"mockdatacfc", "shortDescription":"MockData is a service to generate fake JSON data via command line arguments, CFC calls or embedded RESTFul service", "type":"modules", diff --git a/readme.md b/readme.md index 7f2670e..4dc698b 100755 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/Ortus-Solutions/MockDataCFC.svg?branch=development)](https://travis-ci.org/Ortus-Solutions/MockDataCFC) +[![Build Status](https://travis-ci.org/coldbox-modules/MockDataCFC.svg?branch=development)](https://travis-ci.org/coldbox-modules/MockDataCFC) # MockData CFC From 5b535fd330174d76cc9ea3363fbc7a99951d0e86 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 9 May 2024 22:29:40 +0200 Subject: [PATCH 09/13] - Github actions updates - ColdBox 7 auto testing - Markdown linting --- .github/workflows/pr.yml | 2 +- .github/workflows/release.yml | 6 +- .github/workflows/snapshot.yml | 2 +- .github/workflows/tests.yml | 19 ++--- .markdownlint.json | 6 +- build/Build.cfc | 4 +- changelog.md | 124 +++++++++++++++++---------------- server-adobe@2023.json | 2 +- server-lucee@6.json | 23 ++++++ test-harness/box.json | 2 +- test-harness/layouts/Main.cfm | 12 ++-- 11 files changed, 117 insertions(+), 85 deletions(-) create mode 100644 server-lucee@6.json diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 7018845..2971af2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a1d896..6665ab3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup CommandBox uses: Ortus-Solutions/setup-commandbox@v2.0.1 @@ -82,7 +82,7 @@ jobs: - name: Upload Build Artifacts if: success() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.MODULE_ID }} path: | @@ -138,7 +138,7 @@ jobs: steps: # Checkout development - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: development diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 45d7dd1..63aca2e 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -20,7 +20,7 @@ jobs: name: Code Auto-Formatting runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Auto-format uses: Ortus-Solutions/commandbox-action@v1.0.2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2d10f11..a2548fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,25 +18,28 @@ jobs: strategy: fail-fast: false matrix: - cfengine: [ "lucee@5", "adobe@2018", "adobe@2021" ] - coldboxVersion: [ "^6.0.0" ] + cfengine: [ "lucee@5", "adobe@2018", "adobe@2021", "adobe@2023" ] + coldboxVersion: [ "^6.0.0", "^7.0.0" ] experimental: [ false ] include: - - cfengine: "adobe@2023" - coldboxVersion: "^6.0.0" - experimental: true - coldboxVersion: "be" cfengine: "lucee@5" experimental: true + - coldboxVersion: "be" + cfengine: "lucee@6" + experimental: true - coldboxVersion: "be" cfengine: "adobe@2018" experimental: true - coldboxVersion: "be" cfengine: "adobe@2021" experimental: true + - coldboxVersion: "be" + cfengine: "adobe@2023" + experimental: true steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Not Needed in this module #- name: Setup Database and Fixtures @@ -96,7 +99,7 @@ jobs: - name: Upload Test Results to Artifacts if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: test-results-${{ matrix.cfengine }}-${{ matrix.coldboxVersion }} path: | @@ -109,7 +112,7 @@ jobs: - name: Upload Debug Logs To Artifacts if: ${{ failure() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Failure Debugging Info - ${{ matrix.cfengine }} - ${{ matrix.coldboxVersion }} path: | diff --git a/.markdownlint.json b/.markdownlint.json index 31705fa..21bc843 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -10,5 +10,7 @@ }, "no-duplicate-header" : { "siblings_only" : true - } -} \ No newline at end of file + }, + "no-duplicate-heading" : false, + "no-inline-html" : false +} diff --git a/build/Build.cfc b/build/Build.cfc index ee9366e..b15a671 100644 --- a/build/Build.cfc +++ b/build/Build.cfc @@ -12,6 +12,7 @@ component { variables.cwd = getCWD().reReplace( "\.$", "" ); variables.artifactsDir = cwd & "/.artifacts"; variables.buildDir = cwd & "/.tmp"; + variables.apidDocsDir = variables.buildDir & "/apidocs"; variables.apiDocsURL = "http://localhost:60299/apidocs/"; variables.testRunner = "http://localhost:60299/tests/runner.cfm"; @@ -31,7 +32,8 @@ component { // Cleanup + Init Build Directories [ variables.buildDir, - variables.artifactsDir + variables.artifactsDir, + variables.apidDocsDir ].each( function( item ){ if ( directoryExists( item ) ) { directoryDelete( item, true ); diff --git a/changelog.md b/changelog.md index 27b288f..67066dc 100644 --- a/changelog.md +++ b/changelog.md @@ -11,102 +11,104 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Build Updates - Github actions updates - ColdBox 7 auto testing +- Markdown linting ## [3.6.0] => 2022-SEP-22 ### Added -* New module layout +- New module layout ### Fixed -* DateRanges +- DateRanges ## [3.5.0] => 2022-JAN-11 ### Added -* Github actions migration -* Formatting and code quality rules -* `guid` generator thanks to @djcard +- Github actions migration +- Formatting and code quality rules +- `guid` generator thanks to @djcard ## [3.4.0] => 2020-JUN-03 ### Added -* `string` type re-architected to produce more randomness and more permutations according to our new generation pattern: `string[-(secure|alpha|numeric):max]` #6 -* More formatting rules -* Changelog standards -* Auto publishing to github (artifacts and changelogs) -* Types are now case-insensitive when called: `num,oneof,lorem,baconlorem,sentence,words` #5 -* `generateFakeData()` is now public -* All generators can now be called individually by function name -* `lorem,baconlorem,words,sentence` you can now produce random sizes with them via `min:max` notation -* Optimized generation by using arrays instead of strings -* Included libraries for nouns and adjectives +- `string` type re-architected to produce more randomness and more permutations according to our new generation pattern: `string[-(secure|alpha|numeric):max]` #6 +- More formatting rules +- Changelog standards +- Auto publishing to github (artifacts and changelogs) +- Types are now case-insensitive when called: `num,oneof,lorem,baconlorem,sentence,words` #5 +- `generateFakeData()` is now public +- All generators can now be called individually by function name +- `lorem,baconlorem,words,sentence` you can now produce random sizes with them via `min:max` notation +- Optimized generation by using arrays instead of strings +- Included libraries for nouns and adjectives ### Changed -* Access variables according to scopes instead of lookup -* Internal data generation names to avoid method conflicts +- Access variables according to scopes instead of lookup +- Internal data generation names to avoid method conflicts ### Fixed -* Access variables according to scopes -* `$returnType` is not documented #8 +- Access variables according to scopes +- `$returnType` is not documented #8 ## [3.3.1] => 2020-APR-16 ### Fixed -* param the default method when executing via URL instead of setting it. +- param the default method when executing via URL instead of setting it. ## [3.3.0] => 2020-JAN-28 ### New Features -* `ipaddress` : Generates an ipv4 address -* New type: `string` which generates random hash strings of certain length. Default is 10 characters. -* New type: `website` to generate random protocol based websites -* New type: `website_http` to generate `http` only based websites -* New type: `website_https` to generate `https` only based websites -* New type: `imageurl` : Generates a random image URL with a random protocol -* New type: `imageurl_http` : Generates a random image URL with `http` only protocol -* New type: `imageurl_https` : Generates a random image URL with `https` only protocol -* New type: `url` : Generates a random URL with a random protocol -* New type: `url_http` : Generates a random URL with `http` only protocol -* New type: `url_https` : Generates a random URL with `https` only protocol +- `ipaddress` : Generates an ipv4 address +- New type: `string` which generates random hash strings of certain length. Default is 10 characters. +- New type: `website` to generate random protocol based websites +- New type: `website_http` to generate `http` only based websites +- New type: `website_https` to generate `https` only based websites +- New type: `imageurl` : Generates a random image URL with a random protocol +- New type: `imageurl_http` : Generates a random image URL with `http` only protocol +- New type: `imageurl_https` : Generates a random image URL with `https` only protocol +- New type: `url` : Generates a random URL with a random protocol +- New type: `url_http` : Generates a random URL with `http` only protocol +- New type: `url_https` : Generates a random URL with `https` only protocol ### Improvements -* Added new domains for more random generation -* Removed spacing from words +- Added new domains for more random generation +- Removed spacing from words ## [3.2.0] => 2020-JAN-08 ### New Features -* Added the ability for a type to be a closure/lambda to act as a supplier. This way, this function will be called every time for you to supply the result. It receives the current iterating `index` as well: `function( index ){}` +- Added the ability for a type to be a closure/lambda to act as a supplier. This way, this function will be called every time for you to supply the result. It receives the current iterating `index` as well: `function( index ){}` ### Improvements -* Formatting of source via cfformat -* Fixes for api doc creations to use the project mapping -* Functional update of json service to filter out reserved rc keys -* TestBox 3 upgrade -* More direct scoping of the arguments scope +- Formatting of source via cfformat +- Fixes for api doc creations to use the project mapping +- Functional update of json service to filter out reserved rc keys +- TestBox 3 upgrade +- More direct scoping of the arguments scope ## [3.1.0] => 2019-MAY-19 -* CommandBox ability to execute -* Template updates to standards +- CommandBox ability to execute +- Template updates to standards ## [3.0.0] => 2018-SEP-4 -* **Compatibility** : `num` arguments have been dropped and you must use `$num` as the identifier for how many items you like -* Introduction of nested mocking. You can now declare nested mocks as structs and the mock data will nest accordingly: +- **Compatibility** : `num` arguments have been dropped and you must use `$num` as the identifier for how many items you like +- Introduction of nested mocking. You can now declare nested mocks as structs and the mock data will nest accordingly: ```js getInstance( "MockData@MockDataCFC" ) @@ -126,36 +128,36 @@ getInstance( "MockData@MockDataCFC" ) This will produce top level mock data with 2 books per record. -* Nested Data for array of objects, array of values and simple objects -* ACF Compatibilities -* Updated readmes and syntax updates for modern engines -* Upgraded to new ColdBox module Harness +- Nested Data for array of objects, array of values and simple objects +- ACF Compatibilities +- Updated readmes and syntax updates for modern engines +- Upgraded to new ColdBox module Harness ## [2.4.0] -* Added auto-incrementing ID's FOR REAL this time +- Added auto-incrementing ID's FOR REAL this time ## [2.3.0] -* Added auto-incrementing ID's -* Update on build control -* Syntax Ortus Updates, addition of private methods -* allow for use of `rand` or `rnd` for `num` generators -* Add CORS support for ColdBox REST Module -* Bug on `isDefault()` always returning true. -* Added tests and automation +- Added auto-incrementing ID's +- Update on build control +- Syntax Ortus Updates, addition of private methods +- allow for use of `rand` or `rnd` for `num` generators +- Add CORS support for ColdBox REST Module +- Bug on `isDefault()` always returning true. +- Added tests and automation ## [2.2.0] -* Made it a module as well for ColdBox apps. +- Made it a module as well for ColdBox apps. ## [2.0.0] -* Added support for words, sentences, uuid, bacon lorem, date and datetime -* Added CommandBox Support -* Added Documentation -* Added ability to execute as a CFC instead of only via web service +- Added support for words, sentences, uuid, bacon lorem, date and datetime +- Added CommandBox Support +- Added Documentation +- Added ability to execute as a CFC instead of only via web service ## [1.0.0] -Original by Ray Camden +- Original by Ray Camden diff --git a/server-adobe@2023.json b/server-adobe@2023.json index 86bcb69..8d5b2a5 100644 --- a/server-adobe@2023.json +++ b/server-adobe@2023.json @@ -2,7 +2,7 @@ "name":"MockDataCFC-adobe@2023", "app":{ "serverHomeDirectory":".engine/adobe2023", - "cfengine":"adobe@2023.0.0-beta.1" + "cfengine":"adobe@2023" }, "web":{ "http":{ diff --git a/server-lucee@6.json b/server-lucee@6.json new file mode 100644 index 0000000..b69cf20 --- /dev/null +++ b/server-lucee@6.json @@ -0,0 +1,23 @@ +{ + "name":"mockdatacfc-lucee@6", + "app":{ + "serverHomeDirectory":".engine/lucee6", + "cfengine":"lucee@6" + }, + "web":{ + "http":{ + "port":"60299" + }, + "rewrites":{ + "enable":"true" + }, + "webroot":"test-harness", + "aliases":{ + "/moduleroot/MockDataCFC":"../" + } + }, + "openBrowser":"false", + "cfconfig":{ + "file":".cfconfig.json" + } +} diff --git a/test-harness/box.json b/test-harness/box.json index fe4e7ed..c235d12 100644 --- a/test-harness/box.json +++ b/test-harness/box.json @@ -5,7 +5,7 @@ "private":true, "description":"", "dependencies":{ - "coldbox":"^6.0.0" + "coldbox":"^7.0.0" }, "devDependencies":{ "testbox":"*" diff --git a/test-harness/layouts/Main.cfm b/test-harness/layouts/Main.cfm index 9002345..b50f9ab 100644 --- a/test-harness/layouts/Main.cfm +++ b/test-harness/layouts/Main.cfm @@ -1,6 +1,6 @@ - -

Module Tester

-
- #renderView()# -
-
\ No newline at end of file + +

Module Tester

+
+ #view()# +
+
From ad2a5925b4ab2a09aeea64fd84be636f25f6a364 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 9 May 2024 22:56:46 +0200 Subject: [PATCH 10/13] - New type: `boolean` to create random boolean values as `true` or `false` - New type: `boolean-digit` to create random boolean values as `1` or `0` - New type: `datetime-iso` to create ISO8601 formatted dates - Added separators to the `words()` method - Build Updates - Github actions updates - ColdBox 7 auto testing - Markdown linting - Added more random data --- changelog.md | 5 ++ models/MockData.cfc | 94 +++++++++++++++++++---- readme.md | 3 + test-harness/tests/specs/MockDataTest.cfc | 15 ++++ 4 files changed, 102 insertions(+), 15 deletions(-) diff --git a/changelog.md b/changelog.md index 67066dc..c19db3a 100644 --- a/changelog.md +++ b/changelog.md @@ -11,10 +11,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- New type: `boolean` to create random boolean values as `true` or `false` +- New type: `boolean-digit` to create random boolean values as `1` or `0` +- New type: `datetime-iso` to create ISO8601 formatted dates +- Added separators to the `words()` method - Build Updates - Github actions updates - ColdBox 7 auto testing - Markdown linting +- Added more random data ## [3.6.0] => 2022-SEP-22 diff --git a/models/MockData.cfc b/models/MockData.cfc index 68944dd..c40a143 100644 --- a/models/MockData.cfc +++ b/models/MockData.cfc @@ -64,23 +64,40 @@ component { ]; variables._lastNames = [ + "Allen", "Anderson", "Bearenstein", "Boudreaux", + "Brown", "Camden", "Castro", "Clapton", + "Clark", + "Davis", "Degeneres", "Elias", "Flores", + "Garcia", + "Hall", + "Harris", "Hill", + "Jackson", + "Johnson", + "Jones", + "King", "Lainez", + "Lee", + "Lewis", "Lopez", "Madeiro", "Maggiano", "Marquez", + "Martin", + "Martinez," "Messi", + "Miller", "Moneymaker", + "Moore", "Padgett", "Pilato", "Reyes", @@ -92,37 +109,70 @@ component { "Sharp", "Smith", "Stroz", + "Taylor", + "Thomas", + "Thompson," "Tobias", - "Zelda" + "Walker", + "White", + "Williams," + "Wilson", + "Young", + "Zelda", ]; variables._webDomains = [ "adobe.com", + "amazon.com", "aol.com", "apple.com", "awesome.com", + "bitbucket.org", "box.com", "box.io", "box.net", "boxing.com", - "example.sv.com", + "dropbox.com", + "ebay.com", + "email.com", "example.co.uk", - "example.jp", - "example.edu", "example.com", + "example.edu", + "example.jp", "example.net", - "email.com", - "mail.io", + "example.sv.com", + "facebook.com", + "github.com", "gmail.com", "google.com", + "hulu.com", + "instagram.com", + "linkedin.com", + "mail.io", + "medium.com", "microsoft.com", "msn.com", - "ortus.io", + "netflix.com", "ortus.com", - "sample.io", - "sample.edu", + "ortus.io", + "pinterest.com", + "quora.com", + "reddit.com", "sample.com", + "sample.edu", + "sample.io", + "slack.com", + "snapchat.com", + "stackoverflow.com", "test.com" + "tumblr.com", + "twitch.tv", + "twitter.com", + "udemy.com", + "wikipedia.org", + "wordpress.com", + "yahoo.com", + "zoom.us" ]; variables._loremData = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; @@ -143,8 +193,11 @@ component { "age", "all_age", "baconlorem", + "boolean", + "boolean-digit", "date", "datetime", + "datetime-iso", "email", "fname", "gps", @@ -160,6 +213,9 @@ component { ]; variables._extensions = [ + ".bx", + ".bxs", + ".bxm", ".cfm", ".css", ".doc", @@ -274,6 +330,12 @@ component { if ( arguments.type == "autoincrement" ) { return arguments.index; } + if ( arguments.type == "boolean" ) { + return randRange( 0, 1 ) > 0 ? true : false; + } + if ( arguments.type == "boolean-digit" ) { + return randRange( 0, 1 ); + } if ( arguments.type == "ipaddress" ) { return ipAddress(); } @@ -343,6 +405,9 @@ component { if ( arguments.type == "datetime" ) { return dateRange( showTime = true ); } + if ( arguments.type == "datetime-iso" ) { + return dateRange( showTime = true, dateFormat = "iso" ); + } if ( arguments.type.findNoCase( "num" ) == 1 ) { return num( arguments.type.find( ":" ) ? arguments.type.REreplaceNoCase( "num\:?", "" ) : javacast( @@ -469,8 +534,9 @@ component { * Generate random words * * @size The number of words to generate or can be a min:max range to produce random number of words + * @separator The separtor to use, defaults to empty space */ - function words( size = 1 ){ + function words( size = 1, separator = " " ){ // Do we have a random size request? if ( find( ":", arguments.size ) ) { arguments.size = randRange( getToken( arguments.size, 1, ":" ), getToken( arguments.size, 2, ":" ) ); @@ -484,7 +550,7 @@ component { result.append( variables._adjectives[ randRange( 1, variables._adjectives.len() ) ] ); } } - return result.toList( " " ); + return result.toList( arguments.separator ); } /** @@ -693,14 +759,12 @@ component { * @to The end date else defaults to today * @showTime Show time in the data * @dateFormat The date formatting to use - * @timeFormat The time formmating to use */ function dateRange( date from = "#createDateTime( "2010", "01", "01", "0", "0", "0" )#", date to = "#now()#", showTime = false, - dateFormat = "medium", - timeFormat = "medium" + dateFormat = "medium" ){ var timeDifference = dateDiff( "s", arguments.from, arguments.to ); var result = dateAdd( @@ -710,7 +774,7 @@ component { ); if ( arguments.showTime ) { - return dateFormat( result, arguments.dateFormat ) & " " & timeFormat( result, arguments.timeFormat ); + return dateTimeFormat( result, arguments.dateFormat ); } else { return dateFormat( result, arguments.dateFormat ); } diff --git a/readme.md b/readme.md index 4dc698b..4d6c9ef 100755 --- a/readme.md +++ b/readme.md @@ -132,8 +132,11 @@ The available types MockDataCFC supports are: * `all_age`: Generates a random age of 1 to 100. * `autoincrement` : Returns an incremented index starting from 1 * `baconlorem`: Returns bacon lorem ipsum text. If used as `baconlorem:N`, returns N paragraphs. If used as `baconlorem:X:Y`, returns a random number of paragraphs between X and Y. +* `boolean`: Generates a random boolean value of `true` or `false`. +* `boolean-digit` : Generates a random boolean value as a digit of 0 or 1. * `date`: Generates a random date * `datetime`: Generates a random date and time value +* `datetime-iso` : Generates a random date and time value in ISO format * `email`: Generates a random email. * `fname`: Generates a random first name. * `imageurl` : Generates a random image URL with a random protocol diff --git a/test-harness/tests/specs/MockDataTest.cfc b/test-harness/tests/specs/MockDataTest.cfc index 9659333..50bee70 100644 --- a/test-harness/tests/specs/MockDataTest.cfc +++ b/test-harness/tests/specs/MockDataTest.cfc @@ -84,6 +84,21 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="root" { expect( r[ 1 ].createdOn ).toBeDate(); } ); + it( "can generate iso date times", function(){ + var r = mockDataCFC.mock( createdOn = "datetime-iso" ); + expect( r[ 1 ].createdOn ).toBeDate(); + } ); + + it( "can generate boolean randomness", function(){ + var r = mockDataCFC.mock( isActive : "boolean" ); + expect( r[ 1 ].isActive ).toBeBoolean(); + } ); + + it( "can generate boolean digit randomness", function(){ + var r = mockDataCFC.mock( isActive : "boolean-digit" ); + expect( r[ 1 ].isActive ).toBeBoolean(); + } ); + it( "can generate numbers", function(){ var r = mockDataCFC.mock( value = "num" ); expect( r[ 1 ].value ).toBeNumeric().toBeLTE( 10 ); From a42647f5ab538fc724e8c893ea1d82771e5da55c Mon Sep 17 00:00:00 2001 From: lmajano Date: Thu, 9 May 2024 20:58:33 +0000 Subject: [PATCH 11/13] Apply cfformat changes --- models/MockData.cfc | 4 ++-- test-harness/tests/specs/MockDataTest.cfc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/models/MockData.cfc b/models/MockData.cfc index c40a143..955b134 100644 --- a/models/MockData.cfc +++ b/models/MockData.cfc @@ -118,7 +118,7 @@ component { "Williams," "Wilson", "Young", - "Zelda", + "Zelda" ]; variables._webDomains = [ @@ -533,7 +533,7 @@ component { /** * Generate random words * - * @size The number of words to generate or can be a min:max range to produce random number of words + * @size The number of words to generate or can be a min:max range to produce random number of words * @separator The separtor to use, defaults to empty space */ function words( size = 1, separator = " " ){ diff --git a/test-harness/tests/specs/MockDataTest.cfc b/test-harness/tests/specs/MockDataTest.cfc index 50bee70..ca7a502 100644 --- a/test-harness/tests/specs/MockDataTest.cfc +++ b/test-harness/tests/specs/MockDataTest.cfc @@ -90,12 +90,12 @@ component extends="coldbox.system.testing.BaseTestCase" appMapping="root" { } ); it( "can generate boolean randomness", function(){ - var r = mockDataCFC.mock( isActive : "boolean" ); + var r = mockDataCFC.mock( isActive: "boolean" ); expect( r[ 1 ].isActive ).toBeBoolean(); } ); it( "can generate boolean digit randomness", function(){ - var r = mockDataCFC.mock( isActive : "boolean-digit" ); + var r = mockDataCFC.mock( isActive: "boolean-digit" ); expect( r[ 1 ].isActive ).toBeBoolean(); } ); From f1e31a9445b025e6d2ab35ec8515d6d6a55356b1 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 9 May 2024 23:01:50 +0200 Subject: [PATCH 12/13] fixing periods --- models/MockData.cfc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/MockData.cfc b/models/MockData.cfc index c40a143..b8c8087 100644 --- a/models/MockData.cfc +++ b/models/MockData.cfc @@ -93,7 +93,7 @@ component { "Maggiano", "Marquez", "Martin", - "Martinez," + "Martinez", "Messi", "Miller", "Moneymaker", @@ -111,11 +111,11 @@ component { "Stroz", "Taylor", "Thomas", - "Thompson," + "Thompson", "Tobias", "Walker", "White", - "Williams," + "Williams", "Wilson", "Young", "Zelda", From 484bb99c01c876b809eccc76502e7c91613c9806 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 9 May 2024 23:06:04 +0200 Subject: [PATCH 13/13] missing comma --- models/MockData.cfc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/MockData.cfc b/models/MockData.cfc index 6e440fe..e12fc84 100644 --- a/models/MockData.cfc +++ b/models/MockData.cfc @@ -164,7 +164,7 @@ component { "slack.com", "snapchat.com", "stackoverflow.com", - "test.com" + "test.com", "tumblr.com", "twitch.tv", "twitter.com",