From 801283126bc21c8f1096e687d1b375cbe5c0f23b Mon Sep 17 00:00:00 2001 From: Github Actions Date: Mon, 28 Oct 2024 17:11:50 +0000 Subject: [PATCH 1/4] Version bump --- changelog.md | 6 +++++- gradle.properties | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index d0e5dca..7937d5b 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.10.0] - 2024-10-28 + ### Fixed - Change to `toUnmodifiable` from `toImmutable` @@ -94,7 +96,9 @@ transpiler = { - First iteration of this module -[Unreleased]: https://github.com/ortus-boxlang/bx-compat-cfml/compare/v1.9.0...HEAD +[Unreleased]: https://github.com/ortus-boxlang/bx-compat-cfml/compare/v1.10.0...HEAD + +[1.10.0]: https://github.com/ortus-boxlang/bx-compat-cfml/compare/v1.9.0...v1.10.0 [1.9.0]: https://github.com/ortus-boxlang/bx-compat-cfml/compare/v1.8.0...v1.9.0 diff --git a/gradle.properties b/gradle.properties index c1e6dea..db42fc5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -#Tue Oct 15 15:37:17 UTC 2024 +#Mon Oct 28 17:11:48 UTC 2024 boxlangVersion=1.0.0-snapshot jdkVersion=21 -version=1.10.0 +version=1.11.0 group=ortus.boxlang From 84da8a7a342e59b282fada34c459027a2e456f97 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Mon, 28 Oct 2024 19:52:55 +0100 Subject: [PATCH 2/4] update to standards --- .github/workflows/snapshot.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 79b4e43..97c1d1a 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -10,6 +10,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + MODULE_ID: ${{ github.event.repository.name }} + JDK_VERSION: 21 + jobs: ############################################# # Tests First baby! We fail, no build :( @@ -39,16 +43,11 @@ jobs: uses: actions/setup-java@v4 with: distribution: "temurin" - java-version: 21 + java-version: ${{ env.JDK_VERSION }} - name: Format Java Source run: | ./gradlew spotlessApply --stacktrace - # Not working for some reason - # - name: Format BoxLang Source - # uses: Ortus-Solutions/commandbox-action@v1.0.3 - # with: - # cmd: run-script format - name: Commit Format Changes uses: stefanzweifel/git-auto-commit-action@v5 From 805087f8af8b1b205b7923b718f1c61f68fbc082 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Mon, 28 Oct 2024 19:55:10 +0100 Subject: [PATCH 3/4] more missing compats --- .github/workflows/tests.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c810ea..f62cd42 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,9 +7,13 @@ on: SLACK_WEBHOOK_URL: required: false +env: + MODULE_ID: ${{ github.event.repository.name }} + GRADLE_VERSION: 8.7 + jobs: tests: - name: Tests + name: Tests ${{ github.event.repository.name }} runs-on: ${{ matrix.os }} env: DB_USER: root @@ -42,7 +46,7 @@ jobs: - name: Setup Gradle uses: gradle/gradle-build-action@v3 with: - gradle-version: "8.7" + gradle-version: ${{ env.GRADLE_VERSION }} # - name: Setup Database and Fixtures # run: | @@ -70,9 +74,9 @@ jobs: - name: Test Module run: | - ./gradlew downloadBoxLang + gradle downloadBoxLang # this is done in order to build the module structure before testing - ./gradlew shadowJar test --stacktrace --console=plain + gradle shadowJar test --stacktrace --console=plain - name: Upload Test Results if: always() @@ -83,6 +87,18 @@ jobs: **/build/reports/tests/** **/build/test-results/** + - name: Inform Slack + if: ${{ failure() && github.ref == 'refs/heads/development' }} + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: boxlang + SLACK_COLOR: ${{ job.status }} # or a specific color like 'green' or '#ff00ff' + SLACK_ICON_EMOJI: ":bell:" + SLACK_MESSAGE: "${{ env.MODULE_ID }} Tests FAILED! You broke the build! :(" + SLACK_TITLE: "${{ env.MODULE_ID }} Build Failure" + SLACK_USERNAME: CI + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} + publish-test-results: name: Publish Test Results runs-on: ubuntu-latest From 26dc4e39fa49b11c723b7f29b67d2e810c93bf4e Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Thu, 31 Oct 2024 14:08:28 +0100 Subject: [PATCH 4/4] BL-719 #resolve GetTagData(), GetFunctionData() function not implemented, implement in the COMPAT module --- changelog.md | 4 + .../compat/bifs/system/GetFunctionData.java | 74 +++++++++++++++++ .../compat/bifs/system/GetTagData.java | 79 ++++++++++++++++++ .../modules/compat/util/KeyDictionary.java | 3 + .../bifs/system/GetFunctionDataTest.java | 73 +++++++++++++++++ .../compat/bifs/system/GetTagDataTest.java | 80 +++++++++++++++++++ 6 files changed, 313 insertions(+) create mode 100644 src/main/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionData.java create mode 100644 src/main/java/ortus/boxlang/modules/compat/bifs/system/GetTagData.java create mode 100644 src/test/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionDataTest.java create mode 100644 src/test/java/ortus/boxlang/modules/compat/bifs/system/GetTagDataTest.java diff --git a/changelog.md b/changelog.md index 7937d5b..7280a85 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `getTagData()` and `getFunctionData()` lucee compats + ## [1.10.0] - 2024-10-28 ### Fixed diff --git a/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionData.java b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionData.java new file mode 100644 index 0000000..ca74160 --- /dev/null +++ b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionData.java @@ -0,0 +1,74 @@ +/** + * [BoxLang] + * + * Copyright [2023] [Ortus Solutions, Corp] + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package ortus.boxlang.modules.compat.bifs.system; + +import ortus.boxlang.modules.compat.util.KeyDictionary; +import ortus.boxlang.runtime.bifs.BIF; +import ortus.boxlang.runtime.bifs.BIFDescriptor; +import ortus.boxlang.runtime.bifs.BoxBIF; +import ortus.boxlang.runtime.context.IBoxContext; +import ortus.boxlang.runtime.scopes.ArgumentsScope; +import ortus.boxlang.runtime.types.Argument; +import ortus.boxlang.runtime.types.Array; +import ortus.boxlang.runtime.types.Struct; +import ortus.boxlang.runtime.types.exceptions.BoxValidationException; + +@BoxBIF +public class GetFunctionData extends BIF { + + /** + * Constructor + */ + public GetFunctionData() { + super(); + declaredArguments = new Argument[] { + new Argument( true, Argument.STRING, KeyDictionary.functionName ) + }; + } + + /** + * Lucee compat: Return information to of a Function as Struct + * + * @param context The context in which the BIF is being invoked. + * @param arguments Argument scope for the BIF. + * + * @argument.functionName The BIF function you want information for (Ex: listLen) + */ + public Object _invoke( IBoxContext context, ArgumentsScope arguments ) { + // Namespace is ignored, they never completed the other ones in lucee + String functionName = arguments.getAsString( KeyDictionary.functionName ); + BIFDescriptor descriptor = functionService.getGlobalFunction( functionName ); + + if ( descriptor == null ) { + // Throw Validation Exception + throw new BoxValidationException( "Function not found: " + functionName ); + } + + return Struct.of( + "name", functionName, + "status", "implemented", + "description", "", + "keywords", new Array(), + "returnType", "Any", + "argumentType", "fixed", + "argMin", 0, + "argMax", -1, + "type", "java", + "memeber", Struct.of(), + "arguments", descriptor.getArguments() + ); + } + +} diff --git a/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetTagData.java b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetTagData.java new file mode 100644 index 0000000..fb8c057 --- /dev/null +++ b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetTagData.java @@ -0,0 +1,79 @@ +/** + * [BoxLang] + * + * Copyright [2023] [Ortus Solutions, Corp] + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package ortus.boxlang.modules.compat.bifs.system; + +import ortus.boxlang.modules.compat.util.KeyDictionary; +import ortus.boxlang.runtime.bifs.BIF; +import ortus.boxlang.runtime.bifs.BoxBIF; +import ortus.boxlang.runtime.components.ComponentDescriptor; +import ortus.boxlang.runtime.context.IBoxContext; +import ortus.boxlang.runtime.scopes.ArgumentsScope; +import ortus.boxlang.runtime.types.Argument; +import ortus.boxlang.runtime.types.Struct; +import ortus.boxlang.runtime.types.exceptions.BoxValidationException; + +@BoxBIF +public class GetTagData extends BIF { + + /** + * Constructor + */ + public GetTagData() { + super(); + declaredArguments = new Argument[] { + new Argument( true, Argument.STRING, KeyDictionary.nameSpaceWithSeperator ), + new Argument( true, Argument.STRING, KeyDictionary.tagName ) + }; + } + + /** + * Lucee compat: Return information to a Tag as Struct + * + * @param context The context in which the BIF is being invoked. + * @param arguments Argument scope for the BIF. + * + * @argument.namespaceWithSeperator The namespace of the tag (Ex: cf) + * + * @argument.tagName The name of the tag (Ex: mail, http, dbinfo, etc) + */ + public Object _invoke( IBoxContext context, ArgumentsScope arguments ) { + // Namespace is ignored, they never completed the other ones in lucee + String tagName = arguments.getAsString( KeyDictionary.tagName ); + ComponentDescriptor descriptor = componentService.getComponent( tagName ); + + if ( descriptor == null ) { + // Throw Validation Exception + throw new BoxValidationException( "Tag not found: " + tagName ); + } + + return Struct.of( + "nameSpaceSeperator", "", + "nameSpace", "cf", + "name", tagName, + "description", "", + "status", "implemented", + "attributeType", "fixed", + "parseBody", descriptor.allowsBody(), + "bodyType", descriptor.requiresBody() ? "required" : "free", + "attrMin", 0, + "attrMax", 0, + "hasNameAppendix", false, + "attributeCollection", true, + "type", "java", + "attributes", descriptor.getAttributes() + ); + } + +} diff --git a/src/main/java/ortus/boxlang/modules/compat/util/KeyDictionary.java b/src/main/java/ortus/boxlang/modules/compat/util/KeyDictionary.java index 5705447..5739cf5 100644 --- a/src/main/java/ortus/boxlang/modules/compat/util/KeyDictionary.java +++ b/src/main/java/ortus/boxlang/modules/compat/util/KeyDictionary.java @@ -23,5 +23,8 @@ public class KeyDictionary { public static final Key objectType = Key.of( "objectType" ); public static final Key moduleName = Key.of( "compat-cfml" ); public static final Key jsonEscapeControlCharacters = Key.of( "jsonEscapeControlCharacters" ); + public static final Key nameSpaceWithSeperator = Key.of( "nameSpaceWithSeperator" ); + public static final Key tagName = Key.of( "tagName" ); + public static final Key functionName = Key.of( "functionName" ); } diff --git a/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionDataTest.java b/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionDataTest.java new file mode 100644 index 0000000..50b4d97 --- /dev/null +++ b/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetFunctionDataTest.java @@ -0,0 +1,73 @@ +/** + * [BoxLang] + * + * Copyright [2023] [Ortus Solutions, Corp] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ortus.boxlang.modules.compat.bifs.system; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import ortus.boxlang.runtime.BoxRuntime; +import ortus.boxlang.runtime.context.IBoxContext; +import ortus.boxlang.runtime.context.ScriptingRequestBoxContext; +import ortus.boxlang.runtime.scopes.IScope; +import ortus.boxlang.runtime.scopes.Key; +import ortus.boxlang.runtime.scopes.VariablesScope; +import ortus.boxlang.runtime.types.IStruct; + +public class GetFunctionDataTest { + + static BoxRuntime instance; + IBoxContext context; + IScope variables; + static Key result = new Key( "result" ); + + @BeforeAll + public static void setUp() { + instance = BoxRuntime.getInstance( true ); + } + + @BeforeEach + public void setupEach() { + context = new ScriptingRequestBoxContext( instance.getRuntimeContext() ); + variables = context.getScopeNearby( VariablesScope.name ); + } + + @DisplayName( "It returns tag data" ) + @Test + public void testBIF() { + instance.executeSource( + """ + result = getFunctionData( "listLen" ) + println( result ) + """, + context ); + IStruct data = variables.getAsStruct( result ); + assertThat( data.get( "name" ) ).isEqualTo( "listLen" ); + assertThat( data.get( "description" ) ).isEqualTo( "" ); + assertThat( data.get( "status" ) ).isEqualTo( "implemented" ); + assertThat( data.get( "argMin" ) ).isEqualTo( 0 ); + assertThat( data.get( "argMax" ) ).isEqualTo( -1 ); + assertThat( data.get( "type" ) ).isEqualTo( "java" ); + assertThat( data.getAsStruct( Key.of( "arguments" ) ) ).isNotEmpty(); + } + +} diff --git a/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetTagDataTest.java b/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetTagDataTest.java new file mode 100644 index 0000000..306772d --- /dev/null +++ b/src/test/java/ortus/boxlang/modules/compat/bifs/system/GetTagDataTest.java @@ -0,0 +1,80 @@ +/** + * [BoxLang] + * + * Copyright [2023] [Ortus Solutions, Corp] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ortus.boxlang.modules.compat.bifs.system; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import ortus.boxlang.runtime.BoxRuntime; +import ortus.boxlang.runtime.context.IBoxContext; +import ortus.boxlang.runtime.context.ScriptingRequestBoxContext; +import ortus.boxlang.runtime.scopes.IScope; +import ortus.boxlang.runtime.scopes.Key; +import ortus.boxlang.runtime.scopes.VariablesScope; +import ortus.boxlang.runtime.types.IStruct; + +public class GetTagDataTest { + + static BoxRuntime instance; + IBoxContext context; + IScope variables; + static Key result = new Key( "result" ); + + @BeforeAll + public static void setUp() { + instance = BoxRuntime.getInstance( true ); + } + + @BeforeEach + public void setupEach() { + context = new ScriptingRequestBoxContext( instance.getRuntimeContext() ); + variables = context.getScopeNearby( VariablesScope.name ); + } + + @DisplayName( "It returns tag data" ) + @Test + public void testBIF() { + instance.executeSource( + """ + result = getTagData( "cf", "dbinfo" ) + println( result ) + """, + context ); + IStruct data = variables.getAsStruct( result ); + assertThat( data.get( "nameSpaceSeperator" ) ).isEqualTo( "" ); + assertThat( data.get( "nameSpace" ) ).isEqualTo( "cf" ); + assertThat( data.get( "name" ) ).isEqualTo( "dbinfo" ); + assertThat( data.get( "description" ) ).isEqualTo( "" ); + assertThat( data.get( "status" ) ).isEqualTo( "implemented" ); + assertThat( data.get( "attributeType" ) ).isEqualTo( "fixed" ); + assertThat( data.get( "parseBody" ) ).isEqualTo( false ); + assertThat( data.get( "bodyType" ) ).isEqualTo( "free" ); + assertThat( data.get( "attrMin" ) ).isEqualTo( 0 ); + assertThat( data.get( "attrMax" ) ).isEqualTo( 0 ); + assertThat( data.get( "hasNameAppendix" ) ).isEqualTo( false ); + assertThat( data.get( "attributeCollection" ) ).isEqualTo( true ); + assertThat( data.get( "type" ) ).isEqualTo( "java" ); + assertThat( data.getAsStruct( Key.of( "attributes" ) ) ).isNotEmpty(); + } + +}