forked from finos/morphir-elm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
91 lines (77 loc) · 2.16 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const { series, src, dest } = require('gulp');
const os = require('os')
const path = require('path')
const util = require('util')
const fs = require('fs')
const tmp = require('tmp')
const git = require('isomorphic-git')
const http = require('isomorphic-git/http/node')
const del = require('del')
const elmMake = require('node-elm-compiler').compile
const config = {
morphirJvmVersion: '0.7.0',
morphirJvmCloneDir: tmp.dirSync()
}
async function clean() {
return del([
'dist',
'tests-integration/generated'
])
}
async function cloneMorphirJVM() {
return await git.clone({
fs,
http,
dir: config.morphirJvmCloneDir.name,
url: 'https://github.com/finos/morphir-jvm',
ref: `tags/v${config.morphirJvmVersion}`,
singleBranch: true
})
}
function copyMorphirJVMAssets() {
const sdkFiles = path.join(config.morphirJvmCloneDir.name, 'morphir/sdk/core/src*/**')
return src([sdkFiles]).pipe(dest('redistributable/Scala/sdk'))
}
async function cleanupMorphirJVM() {
return del(config.morphirJvmCloneDir.name + '/**', { force: true });
}
function make(rootDir, source, target) {
return elmMake([source], { cwd: path.join(process.cwd(), rootDir), output: target })
}
function makeCLI() {
return make('cli', 'src/Morphir/Elm/CLI.elm', 'Morphir.Elm.CLI.js')
}
function makeDevCLI() {
return make('cli', 'src/Morphir/Elm/DevCLI.elm', 'Morphir.Elm.DevCLI.js')
}
function makeDevServer() {
return make('cli', 'src/Morphir/Web/DevelopApp.elm', 'web/index.html')
}
function makeInsightAPI() {
return make('cli', 'src/Morphir/Web/Insight.elm', 'web/insight.js')
}
function makeTryMorphir() {
return make('cli', 'src/Morphir/Web/TryMorphir.elm', 'web/try-morphir.html')
}
const build =
series(
makeCLI,
makeDevCLI,
makeDevServer,
makeInsightAPI,
makeTryMorphir
)
exports.clean = clean;
exports.makeCLI = makeCLI;
exports.makeDevCLI = makeDevCLI;
exports.build = build;
exports.default =
series(
clean,
series(
cloneMorphirJVM,
copyMorphirJVMAssets,
cleanupMorphirJVM
),
build
);