Skip to content

Commit aeb0bb6

Browse files
authored
Frontend dependency management part II (OpenRefine#4621)
Part II for OpenRefine#2423. Partial fix for OpenRefine#3958.
1 parent 2e388cf commit aeb0bb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+201
-18766
lines changed

Diff for: docs/docs/technical-reference/build-test-run.md

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ You will need:
1111
* [OpenRefine source code](https://github.com/OpenRefine/OpenRefine)
1212
* [Java JDK](http://java.sun.com/javase/downloads/index.jsp) (Get [OpenJDK from here](https://adoptium.net/).)
1313
* [Apache Maven](https://maven.apache.org) (OPTIONAL)
14+
* [Node.js](https://nodejs.org/en/download/) and npm
1415
* A Unix/Linux shell environment OR the Windows command line
1516

1617
From the top level directory in the OpenRefine application you can build, test and run OpenRefine using the `./refine` shell script (if you are working in a \*nix shell), or using the `refine.bat` script from the Windows command line. Note that the `refine.bat` on Windows only supports a subset of the functionality, supported by the `refine` shell script. The example commands below are using the `./refine` shell script, and you will need to use `refine.bat` if you are working from the Windows command line.
@@ -154,6 +155,19 @@ MAVEN_HOME=E:\Downloads\apache-maven-3.8.4-bin\apache-maven-3.8.4\
154155

155156
NOTE: You can use Maven commands directly, but running some goals in isolation might fail (try adding the `compile test-compile` goals in your invocation if that is the case).
156157

158+
### Node.js and npm
159+
160+
The OpenRefine webapp requires node and npm to install package dependencies.
161+
Download and install [Node.js](https://nodejs.org). You should then have node and npm intalled. You can check the versions by typing:
162+
```
163+
node -v
164+
npm -v
165+
```
166+
You can update the version of npm to the latest by typing
167+
```
168+
npm install -g npm@latest
169+
```
170+
157171
### Building {#building}
158172

159173
To see what functions are supported by OpenRefine's build system, type

Diff for: main/webapp/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# OpenRefine WebApp
2+
3+
See the main [README.md](../../README.md) for how to build and run OpenRefine.
4+
5+
## Dependencies
6+
7+
Dependencies available in the npm registry are added to package.json.
8+
9+
A few of the dependencies are not available in npm.
10+
11+
* jquery-ui: packages are generated from jquery-ui website (https://jqueryui.com/download/#!version=1.12.1).
12+
* imgAreaSelect: cannot find 0.9.2 version in npm, found 0.9.11-rc.1 on GitHub (https://github.com/odyniec/imgareaselect).
13+
* suggest (4.3a): not in npm, contains fixes from Google Code SVN.
14+
15+
These dependencies are located under `webapp/modules/core/externals`.
16+
17+
## postinstall
18+
19+
When `npm install` runs, a `postinstall` script copies the necessary files from `node_modules` into `webapp\modules\core\3rdparty`.

Diff for: main/webapp/copy-dependencies.js

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import fs from 'fs';
2+
3+
const FROM_DIR = 'node_modules';
4+
const TO_DIR = 'modules/core/3rdparty';
5+
6+
if (!fs.existsSync(TO_DIR)) {
7+
fs.mkdirSync(TO_DIR);
8+
console.log('Directory '+TO_DIR+' created.');
9+
}
10+
11+
try {
12+
const data = fs.readFileSync('dependencies.json', 'utf8');
13+
const dependencies = JSON.parse(data);
14+
15+
const DIRS = dependencies.directories;
16+
for (const dir of DIRS) {
17+
const path = TO_DIR+'/'+dir;
18+
if (!fs.existsSync(path)) {
19+
fs.mkdirSync(path);
20+
console.log('Directory '+path+' created.');
21+
}
22+
}
23+
24+
// paths are relative to the FROM_DIR and TO_DIR
25+
const PATHS = dependencies.files;
26+
27+
for (const item of PATHS) {
28+
const from = item.from;
29+
const fromPath = FROM_DIR + '/' + from;
30+
let to = item.to;
31+
if (to === '') {
32+
to = from;
33+
}
34+
const toPath = TO_DIR + '/' + to;
35+
fs.copyFileSync(fromPath, toPath);
36+
console.log(fromPath + ' was copied to ' + toPath);
37+
}
38+
39+
} catch (err) {
40+
console.log(`Error reading depedencies.json: ${err}`);
41+
process.exit(-1);
42+
43+
}

Diff for: main/webapp/dependencies.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"directories": [
3+
"tablesorter",
4+
"jquery.i18n",
5+
"jquery.i18n/languages",
6+
"select2"
7+
],
8+
"files" : [
9+
{"from": "tablesorter/dist/js/jquery.tablesorter.js", "to": "tablesorter/jquery.tablesorter.js"},
10+
{"from": "tablesorter/dist/css/theme.blue.css", "to": "tablesorter/theme.blue.css"},
11+
{"from": "moment/min/moment-with-locales.js", "to": "moment-with-locales.js"},
12+
{"from": "underscore/underscore.js", "to": "underscore.js"},
13+
{"from": "js-cookie/src/js.cookie.js", "to": "js.cookie.js"},
14+
{"from": "jquery-migrate/dist/jquery-migrate.js", "to": "jquery-migrate.js"},
15+
{"from": "datejs-coolite/build/date.js", "to": "date.js"},
16+
{"from": "jquery/dist/jquery.js", "to": "jquery.js"},
17+
{"from": "select2/select2.css", "to": "select2/select2.css"},
18+
{"from": "select2/select2.js", "to": "select2/select2.js"},
19+
{"from": "select2/select2.png", "to": "select2/select2.png"},
20+
{"from": "select2/select2-spinner.gif", "to": "select2/select2-spinner.gif"},
21+
{"from": "@wikimedia/jquery.i18n/libs/CLDRPluralRuleParser/src/CLDRPluralRuleParser.js", "to": "jquery.i18n/CLDRPluralRuleParser.js"},
22+
{"from": "@wikimedia/jquery.i18n/src/languages/bs.js", "to": "jquery.i18n/languages/bs.js"},
23+
{"from": "@wikimedia/jquery.i18n/src/languages/dsb.js", "to": "jquery.i18n/languages/dsb.js"},
24+
{"from": "@wikimedia/jquery.i18n/src/languages/fi.js", "to": "jquery.i18n/languages/fi.js"},
25+
{"from": "@wikimedia/jquery.i18n/src/languages/ga.js", "to": "jquery.i18n/languages/ga.js"},
26+
{"from": "@wikimedia/jquery.i18n/src/languages/he.js", "to": "jquery.i18n/languages/he.js"},
27+
{"from": "@wikimedia/jquery.i18n/src/languages/hsb.js", "to": "jquery.i18n/languages/hsb.js"},
28+
{"from": "@wikimedia/jquery.i18n/src/languages/hu.js", "to": "jquery.i18n/languages/hu.js"},
29+
{"from": "@wikimedia/jquery.i18n/src/languages/hy.js", "to": "jquery.i18n/languages/hy.js"},
30+
{"from": "@wikimedia/jquery.i18n/src/languages/la.js", "to": "jquery.i18n/languages/la.js"},
31+
{"from": "@wikimedia/jquery.i18n/src/languages/ml.js", "to": "jquery.i18n/languages/ml.js"},
32+
{"from": "@wikimedia/jquery.i18n/src/languages/os.js", "to": "jquery.i18n/languages/os.js"},
33+
{"from": "@wikimedia/jquery.i18n/src/languages/ru.js", "to": "jquery.i18n/languages/ru.js"},
34+
{"from": "@wikimedia/jquery.i18n/src/languages/sl.js", "to": "jquery.i18n/languages/sl.js"},
35+
{"from": "@wikimedia/jquery.i18n/src/languages/uk.js", "to": "jquery.i18n/languages/uk.js"},
36+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.emitter.bidi.js", "to": "jquery.i18n/jquery.i18n.emitter.bidi.js"},
37+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.emitter.js", "to": "jquery.i18n/jquery.i18n.emitter.js"},
38+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.fallbacks.js", "to": "jquery.i18n/jquery.i18n.fallbacks.js"},
39+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.js", "to": "jquery.i18n/jquery.i18n.js"},
40+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.language.js", "to": "jquery.i18n/jquery.i18n.language.js"},
41+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.messagestore.js", "to": "jquery.i18n/jquery.i18n.messagestore.js"},
42+
{"from": "@wikimedia/jquery.i18n/src/jquery.i18n.parser.js", "to": "jquery.i18n/jquery.i18n.parser.js"}
43+
]
44+
}

Diff for: main/webapp/modules/core/MOD-INF/controller.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -332,21 +332,21 @@ function init() {
332332
registerImporting();
333333

334334
var commonModules = [
335-
"externals/jquery-1.12.4.js",
336-
"externals/jquery-migrate-1.4.1.js",
335+
"3rdparty/jquery.js",
336+
"3rdparty/jquery-migrate.js",
337337
"externals/jquery-ui/jquery-ui.js",
338-
"externals/js.cookie.js",
339-
"externals/underscore-min.js",
340-
341-
"externals/CLDRPluralRuleParser.js",
342-
"externals/jquery.i18n.js",
343-
"externals/jquery.i18n.messagestore.js",
344-
"externals/jquery.i18n.fallbacks.js",
345-
"externals/jquery.i18n.parser.js",
346-
"externals/jquery.i18n.emitter.js",
347-
"externals/jquery.i18n.language.js",
348-
"externals/languages/fi.js",
349-
"externals/languages/ru.js",
338+
"3rdparty/js.cookie.js",
339+
"3rdparty/underscore.js",
340+
341+
"3rdparty/jquery.i18n/CLDRPluralRuleParser.js",
342+
"3rdparty/jquery.i18n/jquery.i18n.js",
343+
"3rdparty/jquery.i18n/jquery.i18n.messagestore.js",
344+
"3rdparty/jquery.i18n/jquery.i18n.fallbacks.js",
345+
"3rdparty/jquery.i18n/jquery.i18n.parser.js",
346+
"3rdparty/jquery.i18n/jquery.i18n.emitter.js",
347+
"3rdparty/jquery.i18n/jquery.i18n.language.js",
348+
"3rdparty/jquery.i18n/languages/fi.js",
349+
"3rdparty/jquery.i18n/languages/ru.js",
350350
];
351351

352352
var RC = Packages.com.google.refine.model.recon.ReconConfig;
@@ -356,10 +356,10 @@ function init() {
356356
"index/scripts",
357357
module,
358358
commonModules.concat([
359-
"externals/date.js",
360-
"externals/tablesorter/jquery.tablesorter.min.js",
361-
"externals/moment-with-locales.min.js",
362-
"externals/select2/select2.min.js",
359+
"3rdparty/date.js",
360+
"3rdparty/tablesorter/jquery.tablesorter.js",
361+
"3rdparty/moment-with-locales.js",
362+
"3rdparty/select2/select2.js",
363363

364364
"scripts/util/misc.js",
365365
"scripts/util/url.js",
@@ -404,8 +404,8 @@ function init() {
404404
module,
405405
[
406406
"externals/jquery-ui/css/ui-lightness/jquery-ui.css",
407-
"externals/select2/select2.css",
408-
"externals/tablesorter/theme.blue.css",
407+
"3rdparty/select2/select2.css",
408+
"3rdparty/tablesorter/theme.blue.css",
409409
"styles/jquery-ui-overrides.less",
410410
"styles/common.less",
411411
"styles/pure.css",
@@ -435,7 +435,7 @@ function init() {
435435
module,
436436
commonModules.concat([
437437
"externals/suggest/suggest-4_3a.js",
438-
"externals/date.js",
438+
"3rdparty/date.js",
439439

440440
"scripts/project.js",
441441

Diff for: main/webapp/modules/core/about.html

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@
4343
margin-bottom: 10em;
4444
}
4545
</style>
46-
<script type="text/javascript" src="externals/jquery-1.12.4.min.js"></script>
47-
<script type="text/javascript" src="externals/CLDRPluralRuleParser.js"></script>
48-
<script type="text/javascript" src="externals/jquery.i18n.js"></script>
49-
<script type="text/javascript" src="externals/jquery.i18n.messagestore.js"></script>
50-
<script type="text/javascript" src="externals/jquery.i18n.fallbacks.js"></script>
51-
<script type="text/javascript" src="externals/jquery.i18n.parser.js"></script>
52-
<script type="text/javascript" src="externals/jquery.i18n.emitter.js"></script>
53-
<script type="text/javascript" src="externals/jquery.i18n.language.js"></script>
54-
<script type="text/javascript" src="externals/languages/fi.js"></script>
55-
<script type="text/javascript" src="externals/languages/ru.js"></script>
46+
<script type="text/javascript" src="3rdparty/jquery.js"></script>
47+
<script type="text/javascript" src="3rdparty/jquery.i18n/CLDRPluralRuleParser.js"></script>
48+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.js"></script>
49+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.messagestore.js"></script>
50+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.fallbacks.js"></script>
51+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.parser.js"></script>
52+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.emitter.js"></script>
53+
<script type="text/javascript" src="3rdparty/jquery.i18n/jquery.i18n.language.js"></script>
54+
<script type="text/javascript" src="3rdparty/jquery.i18n/languages/fi.js"></script>
55+
<script type="text/javascript" src="3rdparty/jquery.i18n/languages/ru.js"></script>
5656
<script type="text/javascript" src="scripts/index.js"></script>
5757

5858
</head>

0 commit comments

Comments
 (0)