Skip to content

Commit 0b2b6be

Browse files
Add Gruntfile and fix TypeScript compilation
* Add Gruntfile.js with some tasks for compilation * Add TypeScript as devDependency * Modify node.d.ts to match NativeScript * Fix import in app.ts * Unignore Gruntfile and ignore .d.ts
1 parent da3cdc3 commit 0b2b6be

File tree

7 files changed

+107
-1069
lines changed

7 files changed

+107
-1069
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ npm-debug.log
3131
node_modules
3232
!preuninstall.js
3333
!postinstall.js
34+
!Gruntfile.js
35+
.d.ts

Gruntfile.js

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
var now = new Date().toISOString();
2+
3+
function shallowCopy(obj) {
4+
var result = {};
5+
Object.keys(obj).forEach(function(key) {
6+
result[key] = obj[key];
7+
});
8+
return result;
9+
}
10+
11+
var travisTag = process.env["TRAVIS_TAG"];
12+
13+
module.exports = function(grunt) {
14+
var path = require("path");
15+
16+
grunt.loadNpmTasks("grunt-shell");
17+
18+
grunt.registerTask("set_package_version", function(version) {
19+
version = version || travisTag;
20+
if (!version) {
21+
return;
22+
}
23+
24+
var packageJson = grunt.file.readJSON("package.json");
25+
packageJson.version = version;
26+
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
27+
});
28+
29+
grunt.registerTask("pack", [
30+
"set_package_version",
31+
"shell:build_package",
32+
]);
33+
34+
grunt.registerTask("publish", function(versionTag) {
35+
grunt.config.set('versionTag', versionTag);
36+
grunt.task.run('shell:travis_publish');
37+
});
38+
39+
grunt.initConfig({
40+
pkg: grunt.file.readJSON("package.json"),
41+
42+
ts: {
43+
options: {
44+
target: 'es5',
45+
module: 'commonjs',
46+
sourceMap: true,
47+
declaration: false,
48+
removeComments: false,
49+
noImplicitAny: false,
50+
experimentalDecorators: true,
51+
emitDecoratorMetadata: true
52+
},
53+
54+
devlib: {
55+
src: ["**/*.ts", "!node_modules/**/*.ts", "!declarations.d.ts"],
56+
reference: ".d.ts"
57+
},
58+
59+
release_build: {
60+
src: ["**/*.ts", "!node_modules/**/*.ts", "test/**/*.ts"],
61+
reference: ".d.ts",
62+
options: {
63+
sourceMap: false,
64+
removeComments: true
65+
}
66+
}
67+
},
68+
69+
shell: {
70+
options: {
71+
stdout: true,
72+
stderr: true,
73+
failOnError: true
74+
},
75+
76+
build_package: {
77+
command: "npm pack",
78+
},
79+
80+
travis_publish: {
81+
command: [
82+
'git tag -a <%= versionTag %> -m "nativescript-unit-test-runner v<%= versionTag %>" remotes/origin/master',
83+
'git push origin <%= versionTag %>'
84+
].join('&&')
85+
}
86+
},
87+
88+
clean: {
89+
src: ["**/*.js*", "!**/*.json", "!postinstall.js", "!preuninstall.ts", "!Gruntfile.js", "!node_modules/**/*", "*.tgz"]
90+
}
91+
});
92+
93+
grunt.loadNpmTasks("grunt-contrib-clean");
94+
grunt.loadNpmTasks("grunt-contrib-watch");
95+
grunt.loadNpmTasks("grunt-ts");
96+
97+
grunt.registerTask("default", "ts:devlib");
98+
};

app.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
import {application} from "application";
1+
import * as application from "application";
2+
application.cssFile = "./tns_modules/nativescript-unit-test-runner/app.css";
23
application.start({ moduleName: "./tns_modules/nativescript-unit-test-runner/main-page" });

0 commit comments

Comments
 (0)