From cb02d29ca44ba2a1f10c52e2a2bde767da0fc114 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 4 Apr 2023 11:38:45 -0400 Subject: [PATCH] updated to latest updates --- .github/FUNDING.YML | 1 + .github/ISSUE_TEMPLATE/BUG_REPORT.md | 33 +++++++ .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md | 18 ++++ .github/PULL_REQUEST_TEMPLATE.md | 29 ++++++ .github/workflows/ci.yml | 32 +++---- .github/workflows/gh-release.yml | 19 ++++ .github/workflows/pr.yml | 60 ++---------- .github/workflows/tests.yml | 58 ++++++++++++ CONTRIBUTING.md | 108 ++++++++++++++++++++++ ModuleConfig.cfc | 10 +- box.json | 11 ++- build/.travis.yml | 105 --------------------- build/Build.cfc | 52 +++++++---- build/SetupTemplate.cfc | 94 ++----------------- changelog.md | 2 + 15 files changed, 345 insertions(+), 287 deletions(-) create mode 100644 .github/FUNDING.YML 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/workflows/gh-release.yml create mode 100644 .github/workflows/tests.yml create mode 100644 CONTRIBUTING.md delete mode 100644 build/.travis.yml diff --git a/.github/FUNDING.YML b/.github/FUNDING.YML new file mode 100644 index 0000000..7e59d13 --- /dev/null +++ b/.github/FUNDING.YML @@ -0,0 +1 @@ +patreon: ortussolutions 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/workflows/ci.yml b/.github/workflows/ci.yml index 611cd83..e54164e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,5 @@ -name: @module_name@ CI +name: @MODULE_NAME@ CI -# Only on Development we build snapshots on: push: branches: @@ -11,6 +10,14 @@ env: MODULE_ID: @MODULE_SLUG@ jobs: + ############################################# + # Tests First baby! We fail, no build :( + ############################################# + tests: + uses: ./.github/workflows/tests.yml + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + ############################################# # Build Module ############################################# @@ -19,25 +26,16 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout Repository - uses: actions/checkout@v2 + uses: actions/checkout@v3.2.0 - name: Setup Java - uses: actions/setup-java@v2 + uses: actions/setup-java@v3.9.0 with: - distribution: "adopt" + distribution: "temurin" java-version: "11" - - name: Cache CommandBox Dependencies - uses: actions/cache@v1 - if: ${{ true }} - with: - path: ~/.CommandBox/artifacts - key: ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }} - restore-keys: | - ${{ runner.OS }}-commandbox-cache-${{ hashFiles( 'box.json' ) }} - - name: Setup CommandBox - uses: elpete/setup-commandbox@v1.0.0 + uses: elpete/setup-commandbox@v2.0.1 with: forgeboxAPIKey: ${{ secrets.FORGEBOX_API_TOKEN }} @@ -74,7 +72,7 @@ jobs: - name: Upload Build Artifacts if: success() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3.1.1 with: name: Module Artifacts path: | @@ -118,4 +116,4 @@ jobs: SLACK_MESSAGE: '${{ env.MODULE_ID }} Built with ${{ job.status }}!' SLACK_TITLE: "${{ env.MODULE_ID }} Build" SLACK_USERNAME: CI - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/gh-release.yml b/.github/workflows/gh-release.yml new file mode 100644 index 0000000..3de37b9 --- /dev/null +++ b/.github/workflows/gh-release.yml @@ -0,0 +1,19 @@ +# Publish Github Release +name: Github Release + +on: + push: + tags: + - v[0-9]+.* + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3.2.0 + - uses: taiki-e/create-gh-release-action@v1.6.1 + 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 1afa13c..b77d2c9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,67 +6,23 @@ on: - "main" - "master" - "development" + - "v*" pull_request: branches: + - "v*" - development jobs: tests: - name: Tests - runs-on: ubuntu-20.04 - steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: "adopt" - java-version: "11" - - - name: Setup CommandBox - uses: elpete/setup-commandbox@v1.0.0 - - - name: Install Dependencies - run: | - box install + uses: ./.github/workflows/tests.yml - - 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@v2 - - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: "adopt" - java-version: "11" - - - name: Set Up CommandBox - uses: elpete/setup-commandbox@v1.0.0 - - - name: Install CFFormat - run: box install commandbox-cfformat - - - name: Run CFFormat - run: box run-script format + uses: actions/checkout@v3.2.0 - - name: Commit Format Changes - uses: stefanzweifel/git-auto-commit-action@v4 + - uses: Ortus-Solutions/commandbox-action@v1.0.2 with: - commit_message: Apply cfformat changes \ No newline at end of file + cmd: run-script format:check diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..28df7c8 --- /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@v3.2.0 + + - name: Setup Java + uses: actions/setup-java@v3.9.0 + 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..5e58a85 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,108 @@ +# Contributing Guide + +Hola amigo! I'm really excited that you are interested in contributing to @MODULE_NAME@. 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 @MODULE_NAME@! We :heart: :heart: :heart: love you! + + + + + + +Made with [contributors-img](https://contrib.rocks) diff --git a/ModuleConfig.cfc b/ModuleConfig.cfc index ad1f814..3fa322d 100644 --- a/ModuleConfig.cfc +++ b/ModuleConfig.cfc @@ -1,10 +1,8 @@ /** -********************************************************************************* -* Copyright Since 2014 CommandBox by Ortus Solutions, Corp -* www.coldbox.org | www.ortussolutions.com -******************************************************************************** -* @author -*/ + * Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp + * www.ortussolutions.com + * --- + */ component { this.cfmapping = "@module_slug@"; diff --git a/box.json b/box.json index aeb17d6..f227b1d 100644 --- a/box.json +++ b/box.json @@ -30,9 +30,12 @@ "installPaths":{ }, "scripts":{ + "setupTemplate": "task run taskFile=build/SetupTemplate.cfc", + "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 commands,build,ModuleConfig.cfc --overwrite", - "format:watch":"cfformat watch commands,build,ModuleConfig.cfc", - "format:check":"cfformat check commands,build,ModuleConfig.cfc" + "format":"cfformat run commands,build,ModuleConfig.cfc ./.cfformat.json --overwrite", + "format:watch":"cfformat watch commands,build,ModuleConfig.cfc ./.cfformat.json", + "format:check":"cfformat check commands,build,ModuleConfig.cfc ./.cfformat.json" } -} \ No newline at end of file +} diff --git a/build/.travis.yml b/build/.travis.yml deleted file mode 100644 index 4245481..0000000 --- a/build/.travis.yml +++ /dev/null @@ -1,105 +0,0 @@ -language: java - -notifications: - slack: - secure: FIHlTn/YO7Wgumm1uIqmoEsqjQA7fV0AE94Rjc5yKzM3AquQa8HicgDVVk0d2GrKRnl0xt3j4ZJV//VJyIjlCd/QVKuj48R2ChjEY2im3+99HFPafCUI5/S2uyowKU6mJTFonH9v6p41eqxdbiAxJdDGOT0V2Gpt3UBSNuHz8ED9/aIHqv+P7M+VD6Xd2XYwctPniWlaSWx57sWcnG/VkFG45qFQAyha64uxOOe4M3ZmG/n5FfauZ8cBVLiRKEIr+CyNhh1ujfzi7+4uzMlSNL5t/BbZamAQuZzqGzGQ9RVvIlyPgUGNJtDEE/hWS09aagXF5T6EMj00szizErh4J1/x4qZwml5+TcBN31E0QmAhCtZe85sr3tYgic+hEz9XX1yymQzf/C7n4to2yNvq0r4g51xDk8IuP95WEh7zaqLlvFZvBFgxpHZBMYlRvhytjOYDeIFRMcGwHZcXosaG2ejqDwcGq/LC4oeG4sSwmg9sdRrtcmcanrNqrBka86WYO6LntI3JdZ86/1ACEUHzhCCwvrKELc9Ji1xxGAgS7QKH+s2/hnJuiMyv73gOVLKYC+wPMLt+fvOmPLSEl+PJiAIlToBq1KUBg03RSQLfPOLD7OrJ8VvDZsEPwejqlGDyc4wRglS9OTi7SnN5LYHSDNDdGdREegWqq9qDHEYEVLI= - -env: - # Fill out these global variables for build process - global: - - MODULE_ID=contentbox-cli - -branches: - only: - - development - - master - -sudo: required -dist: focal - -before_install: - # CommandBox Keys - - curl -fsSl https://downloads.ortussolutions.com/debs/gpg | sudo apt-key add - - - sudo echo "deb https://downloads.ortussolutions.com/debs/noarch /" | sudo tee -a - /etc/apt/sources.list.d/commandbox.list - -install: - # Install Commandbox - - sudo apt-get update && sudo apt-get --assume-yes install jq commandbox - # If using auto-publish, you will need to provide your API token with this line: - - box config set endpoints.forgebox.APIToken=$FORGEBOX_API_TOKEN > /dev/null - -script: - # Set Current Version and Travis Tag - - TARGET_VERSION=`cat $TRAVIS_BUILD_DIR/box.json | jq '.version' -r` - - TRAVIS_TAG=${TARGET_VERSION} - - echo "Starting build for ${MODULE_ID} v${TARGET_VERSION}" - # Replace version so builder can issue it - - box package set version=@build.version@+@build.number@ - # run our dependency installs so we can do our CLI Integration tests - - box install - # Create the CommandBox modules folder, for some reason it is not created - - mkdir -p ${HOME}/.CommandBox/cfml/modules - # Link up the module so we can do testing! - - box link --force - # Build Project - - box task run taskfile=build/Build :version=${TARGET_VERSION} :projectName=${MODULE_ID} :buildID=${TRAVIS_BUILD_NUMBER} :branch=${TRAVIS_BRANCH} - -after_failure: - # Spit out our Commandbox log in case we need to debug - - cat `box system-log` - -deploy: - # Module Deployment - - provider: s3 - on: - branch: - - master - - development - skip_cleanup: true - #AWS Credentials need to be set in Travis - access_key_id: $AWS_ACCESS_KEY - secret_access_key: $AWS_ACCESS_SECRET - # Destination - bucket: "downloads.ortussolutions.com" - local-dir: $TRAVIS_BUILD_DIR/.artifacts/$MODULE_ID - upload-dir: ortussolutions/commandbox-modules/$MODULE_ID - acl: public_read - - # API Docs Deployment - - provider: s3 - on: - branch: - - master - - development - skip_cleanup: true - #AWS Credentials need to be set in Travis - access_key_id: $AWS_ACCESS_KEY - secret_access_key: $AWS_ACCESS_SECRET - bucket: "apidocs.ortussolutions.com" - local-dir: $TRAVIS_BUILD_DIR/.tmp/apidocs - upload-dir: commandbox-modules/$MODULE_ID/$TARGET_VERSION - acl: public_read - - # Github Release only on Master - - provider: releases - api_key: ${GITHUB_TOKEN} - on: - branch: - - master - skip_cleanup: true - edge: true - file_glob: true - file: $TRAVIS_BUILD_DIR/.artifacts/$MODULE_ID/**/* - release_notes_file: $TRAVIS_BUILD_DIR/changelog-latest.md - name: v${TRAVIS_TAG} - tag_name: v${TRAVIS_TAG} - overwrite: true - -# Once API Docs and Binaries are deployed to S3 Publish to ForgeBox -after_deploy: - # Move to build out artifact - - cd ${TRAVIS_BUILD_DIR}/.tmp/${MODULE_ID} - - cat box.json - # Only publish once using the lucee matrix - - box forgebox publish diff --git a/build/Build.cfc b/build/Build.cfc index 5a40f2d..6a38ad7 100644 --- a/build/Build.cfc +++ b/build/Build.cfc @@ -20,6 +20,7 @@ component { "build", "test\-harness", "tests", + "docker-compose.yml", "^\..*" ]; @@ -89,6 +90,7 @@ component { */ function runTests(){ // Tests First, if they fail then exit + print.blueLine( "Testing the package, please wait..." ).toConsole(); // Check Exit Code? if ( shell.getExitCode() ) { @@ -111,15 +113,14 @@ component { branch = "development" ){ // Build Notice ID - print.line() + 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#"; @@ -130,7 +131,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 @@ -143,7 +144,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#/**", @@ -152,7 +153,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#/**", @@ -163,7 +164,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#", @@ -187,8 +188,9 @@ 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 ); command( "docbox generate" ) @@ -201,10 +203,10 @@ component { ) .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#", @@ -218,10 +220,10 @@ component { * Build the latest changelog file: changelog-latest.md */ function latestChangelog(){ - print.blueLine( "+ Building latest changelog..." ).toConsole(); + print.blueLine( "Building latest changelog..." ).toConsole(); if ( !fileExists( variables.cwd & "changelog.md" ) ) { - return error( "X Cannot continue building, changelog.md file doesn't exist!" ); + return error( "Cannot continue building, changelog.md file doesn't exist!" ); } fileWrite( @@ -229,7 +231,8 @@ component { fileRead( variables.cwd & "changelog.md" ).split( "----" )[ 2 ].trim() & chr( 13 ) & chr( 10 ) ); - print.greenBoldLine( " √ Latest changelog file created at `changelog-latest.md`" ) + print + .greenLine( "Latest changelog file created at `changelog-latest.md`" ) .line() .line( fileRead( variables.cwd & "changelog-latest.md" ) ); } @@ -280,10 +283,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, "" ), @@ -300,4 +303,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/SetupTemplate.cfc b/build/SetupTemplate.cfc index 441eb6b..ca18f24 100644 --- a/build/SetupTemplate.cfc +++ b/build/SetupTemplate.cfc @@ -8,7 +8,7 @@ component { */ function init(){ // Setup Pathing - variables.cwd = getCWD().reReplace( "\.$", "" ); + variables.cwd = getCWD().reReplace( "\.$", "" ); return this; } @@ -17,6 +17,12 @@ component { */ function run(){ + // remove old .git + //directoryDelete( variables.cwd & ".git", true ); + + // Create new git repo + //command( "!git init" ).run(); + var moduleName = ask( "What is the human readable name of your module?" ); if( !len( moduleName ) ){ error( "Module Name is required" ); @@ -57,92 +63,8 @@ component { // Finalize Message print .line() - .boldMagentaLine( "Your module template is now ready for development! Go rock it!" ) + .boldMagentaLine( "Your module template is now ready for development! Just add the github origin, commit some code and Go rock it!" ) .toConsole(); } - /** - * Build the source - * - * @projectName The project name used for resources and slugs - * @version The version you are building - * @buldID The build identifier - * @branch The branch you are building - */ - function buildSource( - required projectName, - version = "1.0.0", - buildID = createUUID(), - branch = "development" - ){ - // Build Notice ID - print - .line() - .boldMagentaLine( - "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 ); - - // Project Build Dir - variables.projectBuildDir = variables.buildDir & "/#projectName#"; - directoryCreate( - variables.projectBuildDir, - true, - true - ); - - // Copy source - print.blueLine( "Copying source to build folder..." ).toConsole(); - copy( - variables.cwd, - variables.projectBuildDir - ); - - // Create build ID - fileWrite( - "#variables.projectBuildDir#/#projectName#-#version#+#buildID#", - "Built with love on #dateTimeFormat( now(), "full" )#" - ); - - // Updating Placeholders - print.greenLine( "Updating version identifier to #arguments.version#" ).toConsole(); - command( "tokenReplace" ) - .params( - path = "/#variables.projectBuildDir#/**", - token = "@build.version@", - replacement = arguments.version - ) - .run(); - - print.greenLine( "Updating build identifier to #arguments.buildID#" ).toConsole(); - command( "tokenReplace" ) - .params( - path = "/#variables.projectBuildDir#/**", - token = ( arguments.branch == "master" ? "@build.number@" : "+@build.number@" ), - replacement = ( arguments.branch == "master" ? arguments.buildID : "-snapshot" ) - ) - .run(); - - // zip up source - var destination = "#variables.exportsDir#/#projectName#-#version#.zip"; - print.greenLine( "Zipping code to #destination#" ).toConsole(); - cfzip( - action = "zip", - file = "#destination#", - source = "#variables.projectBuildDir#", - overwrite = true, - recurse = true - ); - - // Copy box.json for convenience - fileCopy( - "#variables.projectBuildDir#/box.json", - variables.exportsDir - ); - } - } diff --git a/changelog.md b/changelog.md index 3a482a2..7c9a395 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ---- +## [Unreleased] + ## [v1.0.0] => 2021-JUN-29 * Initial Creation of this project