Skip to content

Commit

Permalink
chore: #WB2-598, update angularjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ccreusat authored and juniorode committed Jan 8, 2025
1 parent e3adf1f commit 17817e0
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 92 deletions.
80 changes: 57 additions & 23 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ then
fi

case `uname -s` in
MINGW*)
MINGW* | Darwin*)
USER_UID=1000
GROUP_UID=1000
;;
Expand All @@ -20,14 +20,39 @@ case `uname -s` in
fi
esac

# Options
NO_DOCKER=""
SPRINGBOARD="recette"
for i in "$@"
do
case $i in
-s=*|--springboard=*)
SPRINGBOARD="${i#*=}"
shift
;;
--no-docker*)
NO_DOCKER="true"
shift
;;
*)
;;
esac
done

init() {
me=`id -u`:`id -g`
echo "DEFAULT_DOCKER_USER=$me" > .env
}

clean () {
docker compose run --rm maven mvn $MVN_OPTS clean
}
if [ "$NO_DOCKER" = "true" ] ; then
rm -rf node_modules
rm -f yarn.lock
mvn clean
else
docker compose run --rm maven mvn $MVN_OPTS clean
fi
}

install () {
docker compose run --rm maven mvn $MVN_OPTS install -DskipTests
Expand All @@ -54,31 +79,36 @@ buildNode () {
echo "[buildNode] Use entcore version from package.json ($BRANCH_NAME)"
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && npm update entcore && node_modules/gulp/bin/gulp.js build"
if [ "$NO_DOCKER" = "true" ] ; then
yarn install --no-bin-links && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build
else
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --no-bin-links --legacy-peer-deps --force && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build"
fi
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && npm update entcore && node_modules/gulp/bin/gulp.js build"
if [ "$NO_DOCKER" = "true" ] ; then
yarn install && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build
else
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --legacy-peer-deps --force && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build"
fi
esac
else
echo "[buildNode] Use entcore tag $BRANCH_NAME"
entcore_tags=$(npm dist-tags ls entcore)
if [[ $entcore_tags == *"$BRANCH_NAME"* ]]; then
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && npm rm --no-save entcore && npm install --no-save entcore@$BRANCH_NAME && node_modules/gulp/bin/gulp.js build"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && npm rm --no-save entcore && npm install --no-save entcore@$BRANCH_NAME && node_modules/gulp/bin/gulp.js build"
esac
else
case `uname -s` in
MINGW*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install --no-bin-links && node_modules/gulp/bin/gulp.js build"
;;
*)
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "npm install && node_modules/gulp/bin/gulp.js build"
esac
fi
case `uname -s` in
MINGW*)
if [ "$NO_DOCKER" = "true" ] ; then
yarn install && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build
else
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --no-bin-links --legacy-peer-deps --force && npm rm --no-save entcore && yarn install --no-save entcore@dev && node_modules/gulp/bin/gulp.js build"
fi
;;
*)
if [ "$NO_DOCKER" = "true" ] ; then
yarn install --no-bin-links && yarn upgrade entcore && node_modules/gulp/bin/gulp.js build
else
docker compose run --rm -u "$USER_UID:$GROUP_GID" node sh -c "yarn install --legacy-peer-deps --force && npm rm --no-save entcore && yarn install --no-save entcore@dev && node_modules/gulp/bin/gulp.js build"
fi
esac
fi
}

Expand All @@ -94,6 +124,7 @@ testNode () {
esac
}


publish() {
version=`docker compose run --rm maven mvn $MVN_OPTS help:evaluate -Dexpression=project.version -q -DforceStdout`
level=`echo $version | cut -d'-' -f3`
Expand All @@ -120,6 +151,9 @@ do
install)
buildNode && install
;;
watch)
watch
;;
publish)
publish
;;
Expand Down
6 changes: 2 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ services:
MAVEN_CONFIG: /var/maven/.m2

node:
image: opendigitaleducation/node:10-alpine
image: opendigitaleducation/node:16-alpine
working_dir: /home/node/app
volumes:
- ./:/home/node/app
- ~/.npm:/.npm
- ~/.npmrc:/home/node/.npmrc
- ~/.bowerrc:/home/node/.bowerrc

- ../recette:/home/node/recette
149 changes: 90 additions & 59 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,102 @@
var gulp = require('gulp');
var webpack = require('webpack-stream');
var merge = require('merge2');
const replace = require('gulp-replace');
var clean = require('gulp-clean');
var argv = require('yargs').argv;
var fs = require('fs');
const gulp = require("gulp");
const webpack = require("webpack-stream");
const merge = require("merge2");
const replace = require("gulp-replace");
const clean = require("gulp-clean");
const argv = require("yargs").argv;
const fs = require("fs");

gulp.task('drop-cache', function(){
return gulp.src(['./src/main/resources/public/dist'], { read: false })
.pipe(clean());
});
function dropCache() {
return gulp
.src(["./src/main/resources/public/dist"], {
read: false,
allowEmpty: true,
})
.pipe(clean());
}

function buildDev() {
return gulp
.src("./src/main/resources/public")
.pipe(webpack(require("./webpack.config.js")))
.on("error", function handleError() {
this.emit("end"); // Recover from errors
})
.pipe(gulp.dest("./src/main/resources/public/dist"));
}

gulp.task('webpack', ['drop-cache'], () => {
return gulp.src('./src/main/resources/public')
.pipe(webpack(require('./webpack.config.js')))
.on('error', function handleError() {
this.emit('end'); // Recover from errors
})
.pipe(gulp.dest('./src/main/resources/public/dist'));
});
function build(done) {
const refs = gulp
.src("./src/main/resources/view-src/**/*.+(html|json)")
.pipe(replace("@@VERSION", Date.now()))
.pipe(gulp.dest("./src/main/resources/view"));

gulp.task('build', ['webpack'], () => {
var refs = gulp.src("./src/main/resources/view-src/**/*.+(html|json)")
.pipe(replace('@@VERSION', Date.now()))
.pipe(gulp.dest("./src/main/resources/view"));
const copyBehaviours = gulp
.src("./src/main/resources/public/dist/behaviours.js")
.pipe(gulp.dest("./src/main/resources/public/js"));

var copyBehaviours = gulp.src('./src/main/resources/public/dist/behaviours.js')
.pipe(gulp.dest('./src/main/resources/public/js'));
merge[(refs, copyBehaviours)];
done();
}

return merge[refs, copyBehaviours];
});
gulp.task("drop-cache", dropCache);
gulp.task("build-dev", buildDev);
gulp.task("build", build);

function getModName(fileContent){
var getProp = function(prop){
return fileContent.split(prop + '=')[1].split(/\r?\n/)[0];
}
return getProp('modowner') + '~' + getProp('modname') + '~' + getProp('version');
function getModName(fileContent) {
const getProp = function (prop) {
return fileContent.split(prop + "=")[1].split(/\r?\n/)[0];
};
return (
getProp("modowner") + "~" + getProp("modname") + "~" + getProp("version")
);
}

gulp.task('watch', () => {
var springboard = argv.springboard;
if(!springboard){
springboard = '../springboard-open-ent/';
}
if(springboard[springboard.length - 1] !== '/'){
springboard += '/';
}
function watchFiles() {
let springboard = argv.springboard;
if (!springboard) {
springboard = "../springboard-open-ent/";
}
if (springboard[springboard.length - 1] !== "/") {
springboard += "/";
}

gulp.watch('./src/main/resources/public/ts/**/*.ts', () => gulp.start('build'));
gulp.watch(
"./src/main/resources/public/ts/**/*.ts",
gulp.series("drop-cache", "build-dev", "build")
);

fs.readFile("./gradle.properties", "utf8", function(err, content){
var modName = getModName(content);
gulp.watch(['./src/main/resources/public/js'], () => {
console.log('Copying resources to ' + springboard + 'mods/' + modName);
gulp.src('./src/main/resources/**/*')
.pipe(gulp.dest(springboard + 'mods/' + modName));
});
gulp.watch(['./src/main/resources/public/template/**/*.html', '!./src/main/resources/public/template/entcore/*.html'], () => {
console.log('Copying resources to ' + springboard + 'mods/' + modName);
gulp.src('./src/main/resources/**/*')
.pipe(gulp.dest(springboard + 'mods/' + modName));
});
fs.readFile("./gradle.properties", "utf8", function (err, content) {
const modName = getModName(content);
gulp.watch(["./src/main/resources/public/js"], () => {
console.log("Copying resources to " + springboard + "mods/" + modName);
gulp
.src("./src/main/resources/**/*")
.pipe(gulp.dest(springboard + "mods/" + modName));
});
gulp.watch(
[
"./src/main/resources/public/template/**/*.html",
"!./src/main/resources/public/template/entcore/*.html",
],
() => {
console.log("Copying resources to " + springboard + "mods/" + modName);
gulp
.src("./src/main/resources/**/*")
.pipe(gulp.dest(springboard + "mods/" + modName));
}
);

gulp.watch('./src/main/resources/view/**/*.html', () => {
console.log('Copying resources to ' + springboard + 'mods/' + modName);
gulp.src('./src/main/resources/**/*')
.pipe(gulp.dest(springboard + 'mods/' + modName));
});
gulp.watch("./src/main/resources/view/**/*.html", () => {
console.log("Copying resources to " + springboard + "mods/" + modName);
gulp
.src("./src/main/resources/**/*")
.pipe(gulp.dest(springboard + "mods/" + modName));
});
});
});
}

gulp.task("watch", watchFiles);

exports.watch = gulp.parallel("watch");
exports.build = gulp.series("drop-cache", "build-dev", "build");
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"core-js": "2.4.1",
"entcore": "dev",
"entcore-toolkit": "1.2.0",
"gulp": "3.9.1",
"gulp-clean": "^0.3.2",
"gulp": "4.0.2",
"gulp-clean": "0.4.0",
"gulp-sourcemaps": "^2.6.0",
"merge2": "^1.1.0",
"merge2": "1.1.0",
"ts-loader": "^3.2.0",
"typescript": "4.8.3",
"webpack": "3.1.0",
Expand All @@ -24,7 +24,7 @@
"rxjs": "5.4.2"
},
"devDependencies": {
"@types/angular": "^1.6.55",
"@types/angular": "1.8.3",
"@types/jest": "^22.2.0",
"@types/jquery": "^2.0.34",
"axios-mock-adapter": "^1.19.0",
Expand All @@ -48,5 +48,9 @@
"bugs": {
"url": "https://github.com/OPEN-ENT-NG/community/issues"
},
"homepage": "https://github.com/OPEN-ENT-NG/community"
}
"homepage": "https://github.com/OPEN-ENT-NG/community",
"packageManager": "yarn@1.22.19",
"engines": {
"node": "16 || 18"
}
}

0 comments on commit 17817e0

Please sign in to comment.