Skip to content

Commit f6483b9

Browse files
author
Saulo Vallory
committed
First working version
1 parent 17cd998 commit f6483b9

File tree

152 files changed

+40222
-4675
lines changed

Some content is hidden

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

152 files changed

+40222
-4675
lines changed

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "tsdoc"]
2+
path = tsdoc
3+
url = https://github.com/theblacksmith/TSDoc.git
4+
[submodule "docs/tutorials"]
5+
path = docs/tutorials
6+
url = https://github.com/theblacksmith/tsm.wiki.git

.node-inspectorrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"webPort": 8080,
3+
"webHost": null,
4+
"debugPort": 5858,
5+
"saveLiveEdit": true,
6+
"hidden": []
7+
}

.project

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>tsm</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.eclipsesource.jshint.ui.builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.nodeclipse.ui.NodeNature</nature>
16+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
17+
</natures>
18+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
excluded=node_modules//*
3+
included=//*.jjs\://*.js\://*.jshintrc\://*.json\://*.mjs\://*.njs\://*.pjs
4+
options=laxcomma\:true
5+
projectSpecificOptions=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
semanticValidation=disabled
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.eclipse.wst.jsdt.launching.JRE_CONTAINER
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Global

Gruntfile.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
async = require("async");
2+
3+
module.exports = function(grunt) {
4+
5+
// Add the grunt-mocha-test tasks.
6+
require('load-grunt-tasks')(grunt);
7+
8+
grunt.initConfig({
9+
10+
clean: {
11+
tests: {
12+
src: ['test/all-tests.js', 'test/single-test.js']
13+
}
14+
},
15+
16+
typescript: {
17+
lib: {
18+
src: ['lib/tsm.ts', 'lib/**/*.ts', "!lib/**/*.d.ts"],
19+
dest: 'lib/tsm.js',
20+
options: {
21+
//module: 'commonjs', //or commonjs
22+
target: 'es5', //or es3
23+
base_path: './',
24+
//sourcemap: true,
25+
//fullSourceMapPath: true,
26+
//declaration: true,
27+
removeComments: false
28+
}
29+
},
30+
tests: {
31+
src: ['test/**/*.spec.ts', "!test/_sample.spec.ts"],
32+
dest: 'test/all-tests.js',
33+
options: {
34+
module: 'commonjs', //or commonjs
35+
target: 'es5', //or es3
36+
//base_path: 'tests/',
37+
//sourcemap: true,
38+
//fullSourceMapPath: true,
39+
//declaration: true,
40+
}
41+
},
42+
43+
// a template for compiling only one test
44+
test: {
45+
src: 'test/**/TARGET.spec.ts',
46+
dest: 'test/single-test.js',
47+
options: {
48+
module: 'commonjs', //or commonjs
49+
target: 'es5', //or es3
50+
//base_path: 'tests/',
51+
//sourcemap: true,
52+
//fullSourceMapPath: true,
53+
//declaration: true,
54+
}
55+
}
56+
},
57+
58+
// Configure a mochaTest task
59+
mochaTest: {
60+
all: {
61+
options: {
62+
reporter: 'spec'
63+
},
64+
src: ['test/all-tests.js']
65+
},
66+
single: {
67+
options: {
68+
reporter: 'spec'
69+
},
70+
src: ['test/single-test.js']
71+
}
72+
}
73+
});
74+
75+
grunt.registerTask('docs', function() {
76+
var tsdoc = require('./tsdoc/src/TSDoc');
77+
var done = this.async();
78+
var onJSDoc = tsdoc.onJSDoc;
79+
80+
tsdoc.onJSDoc = function(error, stdout, stderr) {
81+
onJSDoc(error, stdout, stderr);
82+
done();
83+
};
84+
85+
tsdoc.cmd();
86+
});
87+
88+
grunt.registerTask('compile', ['typescript:lib']);
89+
90+
grunt.registerTask('tests', ['typescript:tests', 'mochaTest:all', 'clean:tests']);
91+
92+
grunt.registerTask('test', function(target) {
93+
94+
console.log(target);
95+
grunt.config('typescript.test.src', grunt.config('typescript.test.src').replace('TARGET', target));
96+
97+
grunt.task.run(['typescript:test', 'mochaTest:single', 'clean:tests']);
98+
});
99+
100+
grunt.registerTask('default', ['compile', 'tests', 'docs']);
101+
102+
};

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
tsm
22
===
33

4-
Typescript module compiler
4+
Typescript module compiler

bin/tsm.js

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* TSM command line tool
5+
*
6+
* @todo Add an init command
7+
*/
8+
9+
var tsm = require('../');
10+
11+
var inquirer = require('inquirer');
12+
var program = require('commander');
13+
var _ = require('underscore');
14+
15+
require('colors');
16+
17+
program
18+
.version('0.0.1')
19+
.description('TypeScript module compiler. Compiles tsm definitions.')
20+
.usage('[options] <module_path>')
21+
.option('<module_path>', 'The path to a module folder or configuration file (*.tsm or package.json)')
22+
.option('--debug', 'Enable tsm debug output')
23+
.option('-v, --verbose', 'Enable verbose output')
24+
.on('--help', showExamples)
25+
.parse(process.argv);
26+
27+
if (!program.args.length) {
28+
showError('module_path is required');
29+
showHelp();
30+
process.exit(1);
31+
};
32+
33+
var path = program.args[0];
34+
35+
if(program.debug) tsm.enableDebug();
36+
if(program.verbose) tsm.setVerboseOn();
37+
// All set, let's go!
38+
try {
39+
tsm.compile(path);
40+
}
41+
catch(err) {
42+
if(program.debug) {
43+
throw err;
44+
}
45+
else {
46+
console.log('We got a problem...'.red);
47+
_((err.message||err).split("\n")).each(function(msg) {
48+
console.log('>> '.red + msg.trim().white);
49+
})
50+
console.log();
51+
process.exit(-1);
52+
}
53+
}
54+
55+
56+
// Helpers
57+
58+
function showError(err) {
59+
console.log( (' Error: '+err).red );
60+
}
61+
62+
function showHelp() {
63+
program.parse(['', '', '-h']);
64+
}
65+
66+
// custom help
67+
function showExamples(){
68+
console.log(' Examples:');
69+
console.log('');
70+
console.log(' $ tsm module.tsm');
71+
console.log(' $ tsm package.json');
72+
console.log(' $ tsm my/module');
73+
console.log('');
74+
}

compile

-4
This file was deleted.

0 commit comments

Comments
 (0)