-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgruntfile.js
122 lines (115 loc) · 4.12 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
module.exports = function (grunt) {
var localConfig = {
typeScriptDeclarations:[
"**/*.d.ts",
"!references.d.ts",
"!node_modules/**/*.*",
"!demo/**/*.*",
"!demo-ng/**/*.*",
"!bin/**/*.*"
],
outDir: "bin/dist/"
}
grunt.initConfig({
clean:{
build:{
src:[localConfig.outDir]
}
},
copy: {
declarations: {
src: localConfig.typeScriptDeclarations,
dest: localConfig.outDir
},
platforms: {
files: [{ expand: true, src: ["platforms/**"], dest: localConfig.outDir }]
},
packageConfig: {
src: "package.json",
dest: localConfig.outDir,
options: {
process: function (content, srcPath) {
var contentAsObject = JSON.parse(content);
contentAsObject.devDependencies = undefined;
contentAsObject.scripts = undefined;
return JSON.stringify(contentAsObject, null, "\t");
}
}
},
readme: {
src: "README.md",
dest: localConfig.outDir,
options: {
process: function (content, srcPath) {
return content.substring(content.indexOf("\n") + 1)
}
}
}
},
exec: {
tsCompile: "npm run tsc -- --outDir " + localConfig.outDir,
// ngCompile: "npm run ngc -- --outDir " + localConfig.outDir,
tslint: "npm run tslint",
checkRequiredReadmeSection: {
cwd: "bin/dist",
cmd: function (section) {
return "cat README.md | grep -q \"# " + section + "\"";
}
},
checkRequiredPackageJsonSection: {
cwd: "bin/dist",
cmd: function (section) {
return "cat package.json | grep -q \"\\\"" + section + "\\\"\"";
}
},
"ci-build-demo": {
cmd: function (platform, demoSuffix) {
return "cd demo" + (demoSuffix != "" ? "-" + demoSuffix : "") + " && npm install && tns build " + platform;
}
},
"ci-webpack-demo": {
cmd: function (platform, demoSuffix) {
return "cd demo" + (demoSuffix != "" ? "-" + demoSuffix : "") + " && npm install && tns build " + platform
+ " --bundle --env.uglify --env.snapshot"
+ (demoSuffix === "ng" ? " --env.aot" : "");
}
},
}
});
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-exec");
grunt.registerTask("compile", [
"clean:build",
"exec:tsCompile",
// "exec:ngCompile",
"copy"
]);
grunt.registerTask("build", [
"exec:tslint",
"compile",
"copy"
]);
grunt.registerTask("ci", "Performs CI builds for the demo projects", function (action, platform) {
if (!platform || platform === "") {
grunt.warn("You must specify a platform (ios or android)!");
}
if (!action || action === "") {
grunt.warn("You must specify an action (build or webpack)!");
}
var baseTask = "exec:ci-" + action.toLowerCase() + "-demo:" + platform.toLowerCase();
grunt.task.run(
baseTask + ":",
// baseTask + ":ng"
);
});
grunt.registerTask("lint", [
"exec:checkRequiredReadmeSection:Installation",
"exec:checkRequiredReadmeSection:Configuration",
"exec:checkRequiredReadmeSection:API",
"exec:checkRequiredReadmeSection:Usage",
"exec:checkRequiredPackageJsonSection:license",
"exec:checkRequiredPackageJsonSection:nativescript",
"exec:tslint",
]);
};