Skip to content

Commit 5eea823

Browse files
authored
Merge pull request #162 from d4rkstar/3.0.0-php
feat(deploy): Added tasks for php in nuv ide
2 parents 27ae33c + 5f95820 commit 5eea823

File tree

7 files changed

+112
-13
lines changed

7 files changed

+112
-13
lines changed

ide/deploy/deploy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
MAINS = ["__main__.py", "index.js"]
18+
MAINS = ["__main__.py", "index.js", "index.php"]
1919

2020
import os
2121
from os.path import exists, isdir
@@ -37,7 +37,7 @@ def extract_args(files):
3737
res = []
3838
for file in files:
3939
#if dry_run:
40-
# print(f": inspecting {file}")
40+
# print(f": inspecting {file}")
4141
if exists(file):
4242
with open(file, "r") as f:
4343
for line in f.readlines():

ide/deploy/scan.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,36 @@
1818
from glob import glob
1919
from .deploy import *
2020

21+
2122
def scan():
2223
# first look for requirements.txt and build the venv (add in set)
2324
deployments = set()
2425
packages = set()
2526

2627
print("> Scan:")
27-
reqs = glob("packages/*/*/requirements.txt") + glob("packages/*/*/package.json")
28+
reqs = glob("packages/*/*/requirements.txt") + \
29+
glob("packages/*/*/package.json") + glob("packages/*/*/composer.json")
2830
# req = reqs[0]
2931
# from util.deploy.deploy import *
3032
for req in reqs:
3133
print(">> Requirements:", req)
3234
sp = req.split("/")
33-
act = build_zip(sp[1],sp[2])
35+
act = build_zip(sp[1], sp[2])
3436
deployments.add(act)
3537
packages.add(sp[1])
36-
37-
mains = glob("packages/*/*/index.js") + glob("packages/*/*/__main__.py")
38+
39+
mains = glob("packages/*/*/index.js") + \
40+
glob("packages/*/*/__main__.py") + glob("packages/*/*/index.php")
3841
# main = mains[2]
39-
for main in mains:
42+
for main in mains:
4043
print(">> Main:", main)
4144
sp = main.split("/")
42-
act = build_action(sp[1],sp[2])
45+
act = build_action(sp[1], sp[2])
4346
deployments.add(act)
44-
packages.add(sp[1])
47+
packages.add(sp[1])
4548

46-
singles = glob("packages/*/*.py") + glob("packages/*/*.js")
49+
singles = glob("packages/*/*.py") + \
50+
glob("packages/*/*.js") + glob("packages/*/*.php")
4751
# single = singles[0]
4852
for single in singles:
4953
print(">> Action:", single)
@@ -56,7 +60,7 @@ def scan():
5660
for package in packages:
5761
print(">> Package:", package)
5862
deploy_package(package)
59-
63+
6064
for action in deployments:
6165
print(">>> Action:", action)
6266
deploy_action(action)

ide/nuvfile.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tasks:
3737
echo "*** 'deploy' (alias for 'nuv ide deploy') to deploy your app to https://$NUVDEV_USERNAME.nuvolaris.dev"
3838
echo "*** 'devel' (alias for 'nuv ide devel') to start incremental development mode"
3939
echo "*** 'login' (alias for 'nuv ide login') to login as a different user"
40-
echo "*** 'nuv ide' for more informations
40+
echo "*** 'nuv ide' for more informations"
4141
echo "*** https://nuvolaris.github.io for online documentation"
4242
echo "**************************************************************************************"
4343
@@ -244,6 +244,8 @@ tasks:
244244
/bin/rm -rvf "$NUV_PWD"/packages/*/*/virtualenv/
245245
echo "*** removing node_modules"
246246
/bin/rm -rvf "$NUV_PWD"/packages/*/*/node_modules/
247+
echo "*** removing vendor"
248+
/bin/rm -rvf "$NUV_PWD"/packages/*/*/vendor/
247249
echo "*** removing .zip"
248250
/bin/rm -vf "$NUV_PWD"/packages/*/*.zip
249251
else die "no packages in current directory"
@@ -261,3 +263,6 @@ tasks:
261263

262264
nodejs:
263265
desc: nodejs subcommand
266+
267+
php:
268+
desc: php subcommand

ide/nuvopts.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Usage:
1313
ide kill
1414
ide python
1515
ide nodejs
16+
ide php
1617

1718
Commands:
1819
ide login login in nuvolaris.dev
@@ -27,3 +28,4 @@ Commands:
2728
ide shell start a shell with current env
2829
ide python python subcommands
2930
ide nodejs nodejs subcommands
31+
ide php php subcommands

ide/php/build-php.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
DIR="${1:?directory}"
20+
ZIP="${2:?zip file}"
21+
cd "$DIR"
22+
composer install
23+
touch vendor/composer.lock
24+
if test -f "$ZIP"
25+
then rm "$ZIP"
26+
fi
27+
zip -r "$ZIP" vendor # >/dev/null
28+
ls -l $ZIP
29+

ide/php/nuvfile.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
version: '3'
19+
20+
tasks:
21+
22+
clean:
23+
silent: true
24+
desc: clean
25+
requires: {var: [DIR]}
26+
cmds:
27+
- test -d "{{.DIR}}" || die "{{.DIR}} not found or not a directory"
28+
- /usr/bin/rm -Rvf {{.DIR}}/vendor {{.DIR}}.zip
29+
30+
zip:
31+
silent: true
32+
desc: build a zip environment
33+
requires: {var: [DIR]}
34+
cmds:
35+
- test -d "{{.DIR}}" || die "{{.DIR}} not found or not a directory"
36+
- |
37+
if test -f "{{.DIR}}/composer.json"
38+
then bash build-php.sh "{{.DIR}}" "{{.DIR}}.zip"
39+
fi
40+
sources:
41+
- "{{.DIR}}/composer.json"
42+
generates:
43+
- "{{.DIR}}/composer.lock"
44+
45+
action:
46+
silent: true
47+
desc: build the action updating the zip
48+
requires: {var: [DIR]}
49+
dir: "{{.DIR}}"
50+
cmds:
51+
- test -d "{{.DIR}}" || die "{{.DIR}} not found or not a directory"
52+
- |
53+
/usr/bin/zip -r {{.DIR}}.zip * -x "vendor/*" -x "*/vendor/*"

ide/util/nuvfile.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ tasks:
3030
then nuv ide python zip DIR="$(realpath "packages/{{.A}}")"
3131
elif test -e "packages/{{.A}}/package.json"
3232
then nuv ide nodejs zip DIR="$(realpath "packages/{{.A}}")"
33-
else echo "no zip environemnt"
33+
elif test -e "packages/{{.A}}/composer.json"
34+
then nuv ide php zip DIR="$(realpath "packages/{{.A}}")"
35+
else echo "no zip environment"
3436
fi
3537
3638
action:
@@ -44,6 +46,8 @@ tasks:
4446
then nuv ide python action DIR="$(realpath "packages/{{.A}}")"
4547
elif test -e "packages/{{.A}}/index.js"
4648
then nuv ide nodejs action DIR="$(realpath "packages/{{.A}}")"
49+
elif test -e "packages/{{.A}}/index.php"
50+
then nuv ide php action DIR="$(realpath "packages/{{.A}}")"
4751
else die "*** unknow action type"
4852
fi
4953
@@ -58,6 +62,8 @@ tasks:
5862
then nuv ide python clean DIR="$(realpath "packages/{{.A}}")"
5963
elif test -d "packages/{{.A}}/node_modules"
6064
then nuv ide nodejs clean DIR="$(realpath "packages/{{.A}}")"
65+
elif test -d "packages/{{.A}}/vendor"
66+
then nuv ide php clean DIR="$(realpath "packages/{{.A}}")"
6167
else echo "nothing to clean"
6268
fi
6369
if test -e "packages/{{.A}}.zip"

0 commit comments

Comments
 (0)