Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #138 from liferay/mountWorkspace
Browse files Browse the repository at this point in the history
mountWorkspace
  • Loading branch information
gamerson authored Aug 24, 2023
2 parents 3eaf8f0 + c390032 commit b87137b
Show file tree
Hide file tree
Showing 57 changed files with 409 additions and 184 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
.gradle
docker/images/localdev-server/workspace/.gradle
tests/work
8 changes: 4 additions & 4 deletions DEVELOPING.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ template. Plan out the operations you need to perform.
template using the wizard. At the end, rather than selecting `Create`,
select `Just show the command`. Copy and save the command that is shown.

e.g. `liferay ext create --noprompt -- --resource-path="template/service-springboot" --workspace-path="service-springboot" --args=package="com.company.service" --args=packagePath="com/company/service"`
e.g. `liferay ext create --noprompt -- --resource-path="template/service-springboot" --project-path="client-extensions/service-springboot" --args=package="com.company.service" --args=packagePath="com/company/service"`

1. Execute this command one time to ensure the project is created.

1. Generate a one-line command which executes the partial using the wizard.
At the end, rather than selecting `Create`, select `Just show the command`. Copy and save the command that is shown.

e.g. `liferay ext create --noprompt -- --resource-path="partial/object-action-springboot" --workspace-path="service-springboot" --args=id="my-object-action" --args=Object="MyObject" --args=package="com.company.service" --args=packagePath="com/company/service" --args=resourcePath="/myobject/action"`
e.g. `liferay ext create --noprompt -- --resource-path="partial/object-action-springboot" --project-path="client-extensions/service-springboot" --args=id="my-object-action" --args=Object="MyObject" --args=package="com.company.service" --args=packagePath="com/company/service" --args=resourcePath="/myobject/action"`

1. Execute the command one time to see the result. The linux `tree` command is ideal for reviewing the outputs of the wizard.

Expand Down Expand Up @@ -106,12 +106,12 @@ template. Plan out the operations you need to perform.
rm -rf * && \
liferay ext create --noprompt -- \
--resource-path="template/service-springboot" \
--workspace-path="service-springboot" \
--project-path="client-extensions/service-springboot" \
--args=package="com.company.service" \
--args=packagePath="com/company/service" && \
liferay ext create --noprompt -- \
--resource-path="partial/object-action-springboot" \
--workspace-path="service-springboot" \
--project-path="client-extensions/service-springboot" \
--args=id="my-object-action" \
--args=Object="MyObject" \
--args=package="com.company.service" \
Expand Down
13 changes: 0 additions & 13 deletions docker/images/localdev-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,6 @@ USER $UNAME

WORKDIR /workspace

# setup a workspace to build client-extensions with

# these commands are sorted from least likely to most likely to change to better cache layers
COPY --chown=$UNAME:$UNAME workspace/gradle/ /workspace/gradle/

COPY --chown=$UNAME:$UNAME workspace/gradlew /workspace/gradlew

COPY --chown=$UNAME:$UNAME workspace/settings.gradle /workspace/settings.gradle

COPY --chown=$UNAME:$UNAME workspace/gradle.properties /workspace/gradle.properties

#COPY --chown=$UNAME:$UNAME workspace/temp_repo /workspace/temp_repo

COPY --chown=$UNAME:$UNAME entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
8 changes: 0 additions & 8 deletions docker/images/localdev-server/workspace/build.gradle

This file was deleted.

6 changes: 0 additions & 6 deletions docker/images/localdev-server/workspace/gradle.properties

This file was deleted.

12 changes: 12 additions & 0 deletions resources/sample/coupon-with-object-actions/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##
## Check GETTING_STARTED.markdown for additional properties and their default
## values.
##

liferay.workspace.bundle.dist.include.metadata=true
liferay.workspace.modules.dir=modules
liferay.workspace.node.package.manager=yarn
liferay.workspace.product=dxp-7.4-u89
liferay.workspace.themes.dir=themes
liferay.workspace.wars.dir=modules
microsoft.translator.subscription.key=
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ buildscript {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}

maven {
url "https://repository.liferay.com/nexus/content/groups/public"
}

//maven {
//url new File(rootProject.projectDir.getAbsolutePath() + "/temp_repo/").toURI()
//}
}
}

Expand Down
22 changes: 15 additions & 7 deletions resources/sample/refresh-samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,52 @@

set -e

LOCALDEV_REPO=${LOCALDEV_REPO:--../}
export RESOURCES_BASE_PATH="${LOCALDEV_REPO}/resources/"
export WORKSPACE_BASE_PATH="${LOCALDEV_REPO}/resources/sample/coupon-with-object-actions"
export WORKSPACE_PATH="${LOCALDEV_REPO}/resources/sample/coupon-with-object-actions"
BUILD_CMD=${LOCALDEV_REPO}/scripts/ext/build.sh
CREATE_CMD=${LOCALDEV_REPO}/scripts/ext/create.py
BUILD_PROJECTS=${BUILD_PROJECTS:-true}

rm -rf $WORKSPACE_BASE_PATH && mkdir -p $WORKSPACE_BASE_PATH
rm -rf $WORKSPACE_PATH && mkdir -p $WORKSPACE_PATH

cp -R "${LOCALDEV_REPO}"/tests/workspace/* "${WORKSPACE_PATH}"

# Warning, these CREATE_ARGS are whitespace sensitive!

CREATE_ARGS="\
--workspace-path=coupon-batch|\
--project-path=client-extensions/coupon-batch|\
--resource-path=template/batch|\
--workspace-path=${WORKSPACE_PATH}|\
--args=id=coupon-batch|\
--args=name=Coupon Batch" $CREATE_CMD

CREATE_ARGS="\
--workspace-path=coupon-service-nodejs|\
--project-path=client-extensions/coupon-service-nodejs|\
--resource-path=template/service-nodejs|\
--workspace-path=${WORKSPACE_PATH}|\
--args=id=coupon-service-nodejs" $CREATE_CMD

CREATE_ARGS="\
--workspace-path=coupon-service-springboot|\
--project-path=client-extensions/coupon-service-springboot|\
--resource-path=template/service-springboot|\
--workspace-path=${WORKSPACE_PATH}|\
--args=package=com.company.service|\
--args=packagePath=com/company/service" $CREATE_CMD

CREATE_ARGS="\
--workspace-path=coupon-service-nodejs|\
--resource-path=partial/object-action-nodejs|\
--project-path=client-extensions/coupon-service-nodejs|\
--workspace-path=${WORKSPACE_PATH}|\
--args=id=coupon-updated-nodejs|\
--args=name=Coupon Updated (Nodejs)|\
--args=Object=Coupon|\
--args=resourcePath=/coupon/updated" $CREATE_CMD

CREATE_ARGS="\
--workspace-path=coupon-service-springboot|\
--project-path=client-extensions/coupon-service-springboot|\
--resource-path=partial/object-action-springboot|\
--workspace-path=${WORKSPACE_PATH}|\
--args=id=coupon-updated-springboot|\
--args=name=Coupon Updated (Springboot)|\
--args=Object=Coupon|\
Expand Down
2 changes: 2 additions & 0 deletions resources/tilt/Tiltfile.configResources
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.clear_enabled_resources()
config.set_enabled_resources(["client-extension-able", "client-extension-baker"])
14 changes: 0 additions & 14 deletions resources/tilt/Tiltfile.debugDxp

This file was deleted.

11 changes: 4 additions & 7 deletions scripts/ext/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
import re
import shutil

workspace_base_path = os.environ.get(
"WORKSPACE_BASE_PATH", "/workspace/client-extensions/"
)
resources_base_path = os.environ.get("RESOURCES_BASE_PATH", "/repo/resources/")
create_argsline = os.environ.get("CREATE_ARGS", "")

parser = argparse.ArgumentParser()
parser.add_argument(
"--workspace-path", help="The workspace relative path", required=True
)
parser.add_argument("--project-path", help="The workspace relative path", required=True)
parser.add_argument(
"--resource-path", help="The resource path inside /repo/resources/", required=True
)
parser.add_argument("--workspace-path", help="The workspace path", required=True)
parser.add_argument("--args", action="append", nargs="+")

create_args = vars(parser.parse_args(args=create_argsline.split("|")))
Expand All @@ -30,7 +26,7 @@
template_args[arr[0]] = arr[1]
template_args[arr[0] + "-alnum"] = re.sub("[\W_]+", "", arr[1])

project_path = os.path.join(workspace_base_path, create_args["workspace_path"])
project_path = os.path.join(create_args["workspace_path"], create_args["project_path"])

template_path = os.path.join(resources_base_path, create_args["resource_path"])

Expand Down Expand Up @@ -69,6 +65,7 @@ def copy_partial(src, dst):
dirs_exist_ok=True,
)
else:
print("Copying template from %s to %s" % (template_path, project_path))
shutil.copytree(
template_path,
project_path,
Expand Down
2 changes: 1 addition & 1 deletion scripts/ext/eject.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import tempfile

workspace_base_path = "/workspace"
workspace_path = "/workspace"
client_extensions_path = "/workspace/client-extensions/"

# python create a user temp dir and delete it when done
Expand Down
37 changes: 0 additions & 37 deletions scripts/tilt/debugDxp.py

This file was deleted.

18 changes: 10 additions & 8 deletions tests/functional/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set -e

trap stopLocaldev EXIT

LIFERAY_CLI_BRANCH="${LIFERAY_CLI_BRANCH:-next}"
LIFERAY_CLI_REMOTE="${LIFERAY_CLI_REMOTE:-https://github.com/liferay/liferay-cli}"
#LIFERAY_CLI_BRANCH="${LIFERAY_CLI_BRANCH:-next}"
#LIFERAY_CLI_REMOTE="${LIFERAY_CLI_REMOTE:-https://github.com/liferay/liferay-cli}"

if [ "$LIFERAY_CLI_BRANCH" != "" ]; then
if [ $(git -C ${LOCALDEV_REPO}/tests/work/liferay rev-parse --is-inside-work-tree 2> /dev/null) ]; then
Expand Down Expand Up @@ -43,6 +43,8 @@ if [ -e ${LOCALDEV_REPO}/tests/work/workspace ]; then
rm -rf ${LOCALDEV_REPO}/tests/work/workspace
fi

$CLI config set cli.update.check false

$CLI config set localdev.resources.dir ${LOCALDEV_REPO}

$CLI config set localdev.resources.sync false
Expand All @@ -51,21 +53,21 @@ $CLI runtime mkcert

$CLI runtime mkcert --install

BASE_PATH=${LOCALDEV_REPO}/tests/work/workspace/client-extensions

mkdir -p $BASE_PATH
BASE_PATH=${LOCALDEV_REPO}/tests/work

export CLI
export WORKSPACE_BASE_PATH="$BASE_PATH"
export RESOURCES_BASE_PATH="${LOCALDEV_REPO}/resources/"
export WORKSPACE_PATH="${LOCALDEV_REPO}/tests/workspace"
export BUILD_PROJECTS="false"

startLocaldev() {
cat >> ${BASE_PATH}/Tiltfile <<EOF
mkdir -p ${WORKSPACE_PATH}/client-extensions
cat >> ${WORKSPACE_PATH}/client-extensions/Tiltfile <<EOF
dxp_buildargs = {
"DXP_BASE_IMAGE": "gamerson/dxp:7.4.13.LOCALDEV-SNAPSHOT-20230818122409"
}
EOF
($CLI ext start -v -d ${WORKSPACE_BASE_PATH} | sed 's/^/localdev start │ /') &
($CLI ext start -v -d ${WORKSPACE_PATH} | sed 's/^/localdev start │ /') &
}

stopLocaldev() {
Expand Down
7 changes: 4 additions & 3 deletions tests/functional/test-mysql-volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a##/}/"; BASEDIR=$(cd "$a"; pwd)
source ${BASEDIR}/_common.sh

$CLI ext create \
-d ${WORKSPACE_BASE_PATH} \
-d ${WORKSPACE_PATH}/ \
-v \
--noprompt \
-- \
--project-path="client-extensions/test-global-css" \
--resource-path="template/global-css" \
--workspace-path="test-global-css" \
--workspace-path="/workspace" \
--args=id="test-global-css" \
--args=name="Test Global CSS"

# copy the Tiltfile.mysql into workspace

cp ${LOCALDEV_REPO}/resources/tilt/Tiltfile.mysql ${WORKSPACE_BASE_PATH}/
cp ${LOCALDEV_REPO}/resources/tilt/Tiltfile.mysql ${WORKSPACE_PATH}/client-extensions/

startLocaldev

Expand Down
5 changes: 3 additions & 2 deletions tests/functional/test-new-casc-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a##/}/"; BASEDIR=$(cd "$a"; pwd)
source ${BASEDIR}/_common.sh

$CLI ext create \
-d ${WORKSPACE_BASE_PATH} \
-d ${WORKSPACE_PATH} \
-v \
--noprompt \
-- \
--resource-path="template/batch" \
--workspace-path="casc/able-batch" \
--project-path="client-extensions/casc/able-batch" \
--workspace-path="/workspace" \
--args=id="able-batch" \
--args=name="Able Batch"

Expand Down
Loading

0 comments on commit b87137b

Please sign in to comment.