diff --git a/.cfformat.json b/.cfformat.json index 0233515..5c04917 100644 --- a/.cfformat.json +++ b/.cfformat.json @@ -59,4 +59,4 @@ "struct.multiline.element_count": 2, "struct.multiline.min_length": 40, "tab_indent": true -} \ No newline at end of file +} 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 a0d6555..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,110 +0,0 @@ -name: ContentBox-CLI CI - -# Only on Development we build snapshots -on: - push: - branches: - - development - - master - -jobs: - ############################################# - # Build Module - ############################################# - build: - name: Build & Publish - runs-on: ubuntu-20.04 - env: - MODULE_ID: contentbox-cli - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: "adopt" - java-version: "11" - - - name: Setup CommandBox - uses: Ortus-Solutions/setup-commandbox@v2.0.0 - with: - forgeboxAPIKey: ${{ secrets.FORGEBOX_API_TOKEN }} - - - name: Install Build Dependencies - run: | - box install - - - name: Setup Environment 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 }} for ${{ env.BRANCH }} v${{ env.VERSION }} - run: | - # Create the CommandBox modules folder, for some reason it is not created - mkdir -p ~/.CommandBox/cfml/modules - # Link up the module so we can do testing! - box link --force - # Build Project - box task run taskfile=build/Build target=run :version=${{ env.VERSION }} :projectName=${{ env.MODULE_ID }} :buildID=${{ github.run_number }} :branch=${{ env.BRANCH }} - - - name: Failure Logs - if: failure() - run: cat `box system-log` - - - name: Upload Build Artifacts - if: success() - uses: actions/upload-artifact@v3 - with: - name: Module Artifacts - 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/commandbox-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: "commandbox-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 0dc77cc..0000000 --- a/.github/workflows/gh-release.yml +++ /dev/null @@ -1,19 +0,0 @@ -# Publish Github Release -name: Github Release - -on: - push: - tags: - - v[0-9]+.* - -jobs: - create-release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/create-gh-release-action@v1.5.0 - with: - # Produced by the build/Build.cfc - changelog: changelog.md - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3f64e40..1a188a9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,56 +6,29 @@ on: - "main" - "master" - "development" + - "releases/v*" pull_request: branches: + - "releases/v*" - development jobs: tests: - name: Tests - runs-on: ubuntu-20.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Setup Java - uses: actions/setup-java@v3 - with: - distribution: "adopt" - java-version: "11" + uses: ./.github/workflows/tests.yml + secrets: inherit - - name: Setup CommandBox - uses: Ortus-Solutions/setup-commandbox@v2.0.0 - - - name: Install Dependencies - run: | - box install - - - name: Run Tests - run: | - # Create the CommandBox modules folder, for some reason it is not created - mkdir -p ~/.CommandBox/cfml/modules - # Link up the module so we can do testing! - box link --force - # Test - box task run taskfile=build/Build target="runTests" - - - name: Failure Logs - if: failure() - run: cat `box system-log` - - format: - name: Format + formatCheck: + name: Checks Source Code Formatting 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 + - name: Setup CommandBox CLI + uses: Ortus-Solutions/setup-commandbox@v2.0.1 with: - cmd: run-script format + install: commandbox-cfformat + warmup: true - - name: Commit Format Changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Apply cfformat changes + - name: Run formatting rules + run: box run-script format:check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0463f97 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,175 @@ +name: ContentBox-CLI CI + +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: contentbox-cli + SNAPSHOT: ${{ inputs.snapshot || false }} + +jobs: + ########################################################################################## + # Build & Publish + ########################################################################################## + build: + name: Build & Publish + runs-on: ubuntu-20.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup CommandBox + uses: Ortus-Solutions/setup-commandbox@v2.0.1 + 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: 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.4 + 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.7.2 + 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@v4 + 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/commandbox-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: "commandbox-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.8.0 + 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@v4 + 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@v4 + 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.4 + 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..3b1e9fb --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,47 @@ +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@v4 + + - name: Setup CommandBox CLI + uses: Ortus-Solutions/setup-commandbox@v2.0.1 + with: + install: commandbox-cfformat + warmup: true + + - name: Run formatting rules + run: box run-script format + + - name: Commit Format Changes + uses: stefanzweifel/git-auto-commit-action@v5 + 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 new file mode 100644 index 0000000..afdd7c8 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,58 @@ +name: Test Suites + +# We are a reusable Workflow only +on: + workflow_call: + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + tests: + name: Tests + runs-on: ubuntu-20.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: "11" + + - name: Setup CommandBox CLI + uses: Ortus-Solutions/setup-commandbox@v2.0.1 + + # 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 Dependencies + run: | + box install + + - name: Run Tests + run: | + # Create the CommandBox modules folder, for some reason it is not created + mkdir -p ~/.CommandBox/cfml/modules + # Link up the module so we can do testing! + box link --force + # Test + box task run taskfile=build/Build target="runTests" + + - name: Failure Logs + if: failure() + run: cat `box system-log` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6f87a82 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,108 @@ +# Contributing Guide + +Hola amigo! I'm really excited that you are interested in contributing to contentbox-cli. 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 contentbox-cli! We :heart: :heart: :heart: love you! + + + + + + +Made with [contributors-img](https://contrib.rocks) diff --git a/box.json b/box.json index b46c5ec..2cff96f 100644 --- a/box.json +++ b/box.json @@ -1,6 +1,6 @@ { "name":"ContentBox CLI", - "version":"1.5.0", + "version":"1.5.1", "location":"https://downloads.ortussolutions.com/ortussolutions/commandbox-modules/contentbox-cli/@build.version@/contentbox-cli-@build.version@.zip", "slug":"contentbox-cli", "author":"Ortus Solutions, Corp", diff --git a/build/Build.cfc b/build/Build.cfc index c7d06e4..de02f4b 100644 --- a/build/Build.cfc +++ b/build/Build.cfc @@ -14,12 +14,14 @@ component { variables.buildDir = cwd & "/.tmp"; variables.apiDocsURL = "http://localhost:60299/apidocs/"; variables.testRunner = "http://localhost:60299/tests/runner.cfm"; + variables.exportsDir = ""; // Source Excludes Not Added to final binary: You can use REGEX variables.excludes = [ "build", "test\-harness", "tests", + "docker-compose.yml", "^\..*" ]; @@ -36,10 +38,7 @@ component { } ); // Create Project Dependency Mappings - // fileSystemUtil.createMapping( - // "contentbox-cli", - // variables.cwd - // ); + // fileSystemUtil.createMapping( "@module_name@", variables.cwd ); return this; } @@ -61,9 +60,6 @@ component { // Create project mapping fileSystemUtil.createMapping( arguments.projectName, variables.cwd ); - // Run the tests - runTests(); - // Build the source buildSource( argumentCollection = arguments ); @@ -74,11 +70,9 @@ component { // checksums buildChecksums(); - // Build latest changelog - latestChangelog(); // Finalize Message - print + variables.print .line() .boldMagentaLine( "Build Process is done! Enjoy your build!" ) .toConsole(); @@ -88,11 +82,29 @@ component { * Run the test suites */ function runTests(){ + variables.print + .line() + .boldGreenLine( "------------------------------------------------" ) + .boldGreenLine( "Starting to execute your tests..." ) + .boldGreenLine( "------------------------------------------------" ) + .toConsole(); + + var sTime = getTickCount(); + // Tests First, if they fail then exit + // Run your tests via the `command()` options here. + command( "task run build/Tests.cfc" ).run(); // Check Exit Code? if ( shell.getExitCode() ) { return error( "X Cannot continue building, tests failed!" ); + } else { + variables.print + .line() + .boldGreenLine( "------------------------------------------------" ) + .boldGreenLine( "All tests passed in #getTickCount() - sTime#ms! Ready to go, great job!" ) + .boldGreenLine( "------------------------------------------------" ) + .toConsole(); } } @@ -111,16 +123,14 @@ component { branch = "development" ){ // Build Notice ID - print + variables.print .line() .boldMagentaLine( - "+ Building #arguments.projectName# v#arguments.version#+#arguments.buildID# from #cwd# using the #arguments.branch# branch." + "Building #arguments.projectName# v#arguments.version#+#arguments.buildID# from #cwd# using the #arguments.branch# branch." ) .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#"; @@ -131,7 +141,7 @@ component { ); // Copy source - print.blueLine( "+ Copying source to build folder..." ).toConsole(); + print.blueLine( "Copying source to build folder..." ).toConsole(); copy( variables.cwd, variables.projectBuildDir @@ -144,7 +154,7 @@ component { ); // Updating Placeholders - print.greenLine( "+ Updating version identifier to #arguments.version#" ).toConsole(); + print.greenLine( "Updating version identifier to #arguments.version#" ).toConsole(); command( "tokenReplace" ) .params( path = "/#variables.projectBuildDir#/**", @@ -153,7 +163,7 @@ component { ) .run(); - print.greenLine( "+ Updating build identifier to #arguments.buildID#" ).toConsole(); + print.greenLine( "Updating build identifier to #arguments.buildID#" ).toConsole(); command( "tokenReplace" ) .params( path = "/#variables.projectBuildDir#/**", @@ -164,7 +174,7 @@ component { // zip up source var destination = "#variables.exportsDir#/#projectName#-#version#.zip"; - print.greenLine( "+ Zipping code to #destination#" ).toConsole(); + print.greenLine( "Zipping code to #destination#" ).toConsole(); cfzip( action = "zip", file = "#destination#", @@ -188,24 +198,26 @@ component { version = "1.0.0", outputDir = ".tmp/apidocs" ){ + ensureExportDir( argumentCollection = arguments ); // Generate Docs - print.greenLine( "+ Generating API Docs, please wait..." ).toConsole(); + print.greenLine( "Generating API Docs, please wait..." ).toConsole(); directoryCreate( arguments.outputDir, true, true ); + // Generate the docs command( "docbox generate" ) .params( "source" = "commands", "excludes" = "", - "mapping" = "contentbox-cli", + "mapping" = "@module_name@", "strategy-projectTitle" = "#arguments.projectName# v#arguments.version#", "strategy-outputDir" = arguments.outputDir ) .run(); - print.greenBoldLine( " √ API Docs produced at #arguments.outputDir#" ).toConsole(); + print.greenLine( "API Docs produced at #arguments.outputDir#" ).toConsole(); var destination = "#variables.exportsDir#/#projectName#-docs-#version#.zip"; - print.greenLine( " +Zipping apidocs to #destination#" ).toConsole(); + print.greenLine( "Zipping apidocs to #destination#" ).toConsole(); cfzip( action = "zip", file = "#destination#", @@ -215,26 +227,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( "X 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 - .greenBoldLine( " √ Latest changelog file created at `changelog-latest.md`" ) - .line() - .line( fileRead( variables.cwd & "changelog-latest.md" ) ); - } /********************************************* PRIVATE HELPERS *********************************************/ @@ -282,10 +274,10 @@ component { ).each( function( item ){ // Copy to target if ( fileExists( item ) ) { - print.blueLine( " > Copying #item#" ).toConsole(); + print.blueLine( "Copying #item#" ).toConsole(); fileCopy( item, target ); } else { - print.greenLine( " > Copying directory #item#" ).toConsole(); + print.greenLine( "Copying directory #item#" ).toConsole(); directoryCopy( item, target & "/" & item.replace( src, "" ), @@ -302,4 +294,19 @@ 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/Tests.cfc b/build/Tests.cfc new file mode 100644 index 0000000..23bee42 --- /dev/null +++ b/build/Tests.cfc @@ -0,0 +1,14 @@ +/** + * This task is used to execute all of your test suite. + * No need to do try/catch we will do that for you. Just write all the commands, assertions you need. + */ +component { + + /** + * Run my test suites + */ + function run(){ + command( "hello help" ).run( returnOutput: 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 d3c521b..79b1b33 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +* Updated github actions for consistency +* `box` binary removed, not sure why it was there in the first place + +## [v1.5.0] => 2023-DEC-14 + ### Added * New Migrations approach of ContentBox 6 diff --git a/commands/contentbox/install.cfc b/commands/contentbox/install.cfc index 60af712..a3d35de 100644 --- a/commands/contentbox/install.cfc +++ b/commands/contentbox/install.cfc @@ -110,8 +110,10 @@ component { // ContentBox 5 ONLY, as it uses ORM DDL, 6 uses migrations // MySQL 8 Bug on Lucee - if ( arguments.contentboxVersion eq 5 && arguments.cfmlEngine.findNoCase( "lucee" ) && arguments.databaseType == "MySQL8" ) { - contentBox5LuceeBug( installDir); + if ( + arguments.contentboxVersion eq 5 && arguments.cfmlEngine.findNoCase( "lucee" ) && arguments.databaseType == "MySQL8" + ) { + contentBox5LuceeBug( installDir ); } // Seed the right CFML Engine to deploy @@ -168,17 +170,17 @@ component { private function startupServer( required cfmlEngine ){ variables.print - .line() - .blueLine( "Please wait while we startup your CommandBox server..." ) - .toConsole(); - command( "server start" ).run(); - sleep( 5000 ); + .line() + .blueLine( "Please wait while we startup your CommandBox server..." ) + .toConsole(); + command( "server start" ).run(); + sleep( 5000 ); - variables.print.greenLine( "√ ContentBox server started, check out the details below:" ); - command( "server info" ).run(); + variables.print.greenLine( "√ ContentBox server started, check out the details below:" ); + command( "server info" ).run(); - variables.print.greenLine( "√ Opening a browser for you to continue with the web installer..." ); - command( "server open" ).run(); + variables.print.greenLine( "√ Opening a browser for you to continue with the web installer..." ); + command( "server open" ).run(); } /**