Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Itb2018 thinking modularly

71 views

Published on

Brad Wood

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Itb2018 thinking modularly

  1. 1. Thinking Modularly Modern CFML Brad Wood @bdw429s
  2. 2. What is a package? Reusable, self contained, self describing, versioned code, functionality, or application building blocks. ● A folder ● A box.json file ● Some code A package could be a single UDF or an entire CMS. What makes it portable is the agreed format of packaging, distribution, and installation.
  3. 3. What is a module? A Box module is everything a package is, but with additional conventions and lifecycle methods defined by ColdBox, ContentBox, CommandBox, etc. ● A folder ● A box.json file ● A ModuleConfig.cfc ● Some code A Module could be a single interceptor or an entire shopping cart. Box modules are “active” the framework loads them and they can run custom logic on registration as well as contribute behaviors or functionality to the base app.
  4. 4. ● Forgebox ○ https://www.forgebox.io ● HTTP(S) ○ http://mysite.com/myPackage.zip ● Git ○ git@github.com:bdw429s/commandbox-fusionreactor.git ● GitHub ○ bdw429s/commandbox-fusionreactor ● Local file/folder ○ C:/folder/myPackage.zip ● Jars ○ https://search.maven.org/remotecontent?filepath=org/jline/jline/3.7.0/jline-3.7.0.jar Installing Packages
  5. 5. ● ColdBox modules ○ cborm, cbvalidation, cbmessagebox ● CommandBox modules ○ Fusion-reactor, bullet train, host updater ● Non-box frameworks/CMSs ○ Preside, FW/1, CFWheels ● Total standalone stuff ○ SecurityUtil, BrewPunk API ForgeBox.io
  6. 6. ● Packages can depend on other packages ● Promotes reusability and smaller, single-purpose packages ● cborm ○ cbvalidation ■ Cb18n ● Dev dependencies ○ Only required for developing on the project (like testing frameworks) ○ Don’t want installed on production ○ Use “install --production” to skip Package Dependencies
  7. 7. CFConfig Example ● Commandbox-cfconfig ○ cfconfig-services ■ lucee-password-util ■ JSONPrettyPrint ■ Adobe-password-util ● propertyFile ■ semver ■ propertyFile
  8. 8. Turn any folder into a package with one CLI command: package init Want some hand holding? package init --wizard Set additional metadata with: package set name=”My Package” Let’s create a package
  9. 9. Scaffold out a new module with one CLI command: coldbox create module myModule Let’s take a look at the ModuleConfig.cfc component { function configure() { } } Let’s create a module
  10. 10. modules/ These are modules managed by CommandBox. Usually 3rd party. Not committed to source control. modules_app/ These are modules that are a core part of your app that you want to be part of the main source repo. CommandBox doesn’t not manage them. Box Module Locations
  11. 11. A ForgeBox account is free, easy, and let’s you publish packages and collaborators forgebox register Already have a ForgeBox account? forgebox login Create a ForgeBox account
  12. 12. ● What happens when your code changes? ● You need to increment the version! ● Semantic versioning ○ Major ○ Minor ○ Patch ○ Prerelease Identifier ○ Build ID Versioning ❏ 5 ❏ 3.2 ❏ 1.7.8 ❏ 1.2.3-alpha ❏ 5.6+0045 ❏ 2-beta.3 ❏ 1.2.3-rc.4+9876
  13. 13. Semver Ranges ● Give me the latest version that starts with 5 ○ 5.x ● Any version greater than 1.0.0 starting with 1.0.1 ○ >1.0.0 ● Any version between 2.0.0 and 2.5.0 inclusive ○ >=2.0.0 <=2.5.0 ○ 2.0.0 - 2.5.0 ● Any one of these exact versions ○ 1.0.0 || 2.0.0 || 3.0.0 ● Allows 1.2.4 and 1.3, but not 2.0 (same as 1.x.x) ○ ^1.2.3
  14. 14. From the CLI install coldbox@4.3 install testbox@<=2.6 In your box.json “dependencies” : { “coldbox” : “4.3”, “Testbox” : “<=2.6” } Install a Specific Version
  15. 15. Automatically increment version numbers in box.json ● bump --major ● bump --minor ● bump --patch If package is a Git repo, a tag will be created that matches the version number. This helps “lock in” the exact commit of this version. Bump Command
  16. 16. ● Arbitrary commands of your choice to run at interception points ● postVersion ● onRelease ● postPublish ● Ties multiple steps together ● Automates repetitive bits ● Boils releasing down to a single command "scripts" : { "postVersion":"package set location='Ortus-Solutions/commandbox-cfconfig#v`package version`'", "onRelease":"publish", "postPublish":"!git push --follow-tags", } Package Scripts
  17. 17. A nice tool for scaffolding box modules complete with tests, Travis-CI builds, and package scripts. module scaffold myCoolModule https://www.forgebox.io/view/cb-module-template cbModuleTemplate Module
  18. 18. ● Your code ● Frameworks ● 3rd party modules ● Your modules ● Git ignores ● box.json ● “Install” command ● --production flag Building Your Apps

×