This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
107 lines (100 loc) · 2.94 KB
/
Gruntfile.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const fs = require("fs");
const path = require("path");
let gruntOptions = null,
appName = "",
appId = "",
tizenCLIPath = "",
tizenScriptPath = "",
tvPath = "",
tvIP = "",
profileName = "",
profilePath = "",
distPath = "dist/debug/",
devToolsAdress,
devToolsPort;
const findDevToolsPort = (err, stdout, stderr, cb) => {
if (err) {
cb(err);
return;
}
cb();
devToolsPort = stdout.match(/port: ([0-9]+)/);
devToolsPort = devToolsPort[1];
devToolsAdress = `${tvIP}:${devToolsPort}`;
};
module.exports = grunt => {
require("load-grunt-tasks")(grunt, {
scope: "devDependencies"
});
if (process.env.NODE_ENV === "production") {
distPath = "dist/release/";
}
if (fs.existsSync("./grunt-options.js")) {
gruntOptions = require("./grunt-options.js");
appName = gruntOptions.appName;
appId = gruntOptions.appId;
tizenCLIPath = gruntOptions.tizenCLIPath;
tizenScriptPath = gruntOptions.tizenScriptPath;
tvPath = gruntOptions.tvPath;
tvIP = gruntOptions.tvIP;
profileName = gruntOptions.profileName;
profilePath = gruntOptions.profilePath;
}
grunt.initConfig({
shell: {
createWgt: {
command: [
`${tizenCLIPath + tizenScriptPath} build-web -- ./${distPath}`,
`${tizenCLIPath + tizenScriptPath} package --sign ${profileName} --type wgt -- ./${distPath}.buildResult`,
`mv ./${distPath}.buildResult/${appName}.wgt ./${distPath}`
].join("&&")
},
deployToTizen: {
command: [
`${tizenCLIPath}/tools/sdb disconnect`,
`${tizenCLIPath}/tools/sdb connect ${tvIP}`,
`${tizenCLIPath}/tools/sdb -e shell pkgcmd -u -n ${appId}`,
`${tizenCLIPath}/tools/sdb install ${__dirname}/${distPath + appName}.wgt`,
`${tizenCLIPath}/tools/sdb -e shell app_launcher -w -s ${appId}.${appName}`
].join("&&"),
options: {
callback: findDevToolsPort
}
},
runDevTools: {
command: () => `google-chrome ${devToolsAdress}`
},
// @TODO check url luncher
createURLLuncherFolder: {
command: [
"node ./config/upgradeVersion.js",
"mkdir -p url-luncher",
`cp ./dist/${appName}.wgt url-luncher`,
"cp ./config/sssp_config.xml url-luncher",
"ls url-luncher",
"http-server url-luncher"
].join("&&")
},
signCertificateToCli: {
command: `${tizenCLIPath +
tizenScriptPath} cli-config -g profiles.path=${profilePath}`
}
},
webpack: {
debug: require("./webpack.config.js")
}
});
grunt.registerTask("wgt-deploy", [
"shell:createWgt",
"shell:deployToTizen",
"shell:runDevTools"
]);
// @TODO check Windows build
grunt.registerTask("deployWin", ["build-debug", "shell:deployWin"]);
// @TODO check url-luncher
grunt.registerTask("url-luncher", [
"build",
"shell:build",
"shell:createURLLuncherFolder"
]);
};