Combine builds and tests generation, add travis ci
This commit is contained in:
Родитель
99cf2951bc
Коммит
8b528dc6bf
|
@ -1,7 +1,4 @@
|
|||
build/node_modules
|
||||
build/typings/
|
||||
node_modules
|
||||
build/*.js
|
||||
tests/generated/*
|
||||
tests/node_modules
|
||||
tests/typings/
|
||||
tests/*.js
|
||||
tests/*.js
|
||||
tests/generated/*
|
|
@ -0,0 +1,27 @@
|
|||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 'stable'
|
||||
- '8'
|
||||
|
||||
sudo: false
|
||||
|
||||
env:
|
||||
- workerCount=2
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
install:
|
||||
- npm install
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
git:
|
||||
depth: 1
|
|
@ -7,9 +7,6 @@ install:
|
|||
- ps: Install-Product node $env:nodejs_version
|
||||
- node --version
|
||||
- npm --version
|
||||
- cd build
|
||||
- npm install
|
||||
- cd ../tests
|
||||
- npm install
|
||||
- npm test
|
||||
|
||||
|
|
|
@ -3,6 +3,22 @@ import path = require('path');
|
|||
import yaml = require('js-yaml');
|
||||
import plist = require('plist');
|
||||
|
||||
enum Language {
|
||||
TypeScript = "TypeScript",
|
||||
TypeScriptReact = "TypeScriptReact"
|
||||
}
|
||||
|
||||
enum Extension {
|
||||
TmLanguage = "tmLanguage",
|
||||
TmTheme = "tmTheme",
|
||||
YamlTmLangauge = "YAML-tmLanguage",
|
||||
YamlTmTheme = "YAML-tmTheme"
|
||||
}
|
||||
|
||||
function file(language: Language, extension: Extension) {
|
||||
return path.join(__dirname, '..', `${language}.${extension}`);
|
||||
}
|
||||
|
||||
function writePlistFile(grammar: any, fileName: string) {
|
||||
const text = plist.build(grammar);
|
||||
fs.writeFileSync(fileName, text);
|
||||
|
@ -40,7 +56,7 @@ function transformGrammarRepository(grammar: any, propertyNames: string[], trans
|
|||
}
|
||||
|
||||
function changeTsToTsxGrammar(grammar: any, variables: any) {
|
||||
const tsxUpdates = updateGrammarVariables(readYaml("../TypeScriptReact.YAML-tmLanguage"), variables);
|
||||
const tsxUpdates = updateGrammarVariables(readYaml(file(Language.TypeScriptReact, Extension.YamlTmLangauge)), variables);
|
||||
|
||||
// Update name, file types, scope name and uuid
|
||||
for (let key in tsxUpdates) {
|
||||
|
@ -96,21 +112,21 @@ function updateGrammarVariables(grammar: any, variables: any) {
|
|||
}
|
||||
|
||||
function buildGrammar() {
|
||||
const tsGrammarBeforeTransformation = readYaml("../TypeScript.YAML-tmLanguage");
|
||||
const tsGrammarBeforeTransformation = readYaml(file(Language.TypeScript, Extension.YamlTmLangauge));
|
||||
const variables = tsGrammarBeforeTransformation.variables;
|
||||
|
||||
const tsGrammar = updateGrammarVariables(tsGrammarBeforeTransformation, variables);
|
||||
|
||||
// Write TypeScript.tmLanguage
|
||||
writePlistFile(tsGrammar, "../TypeScript.tmLanguage");
|
||||
writePlistFile(tsGrammar, file(Language.TypeScript, Extension.TmLanguage));
|
||||
|
||||
// Write TypeScriptReact.tmLangauge
|
||||
const tsxGrammar = changeTsToTsxGrammar(tsGrammar, variables);
|
||||
writePlistFile(tsxGrammar, "../TypeScriptReact.tmLanguage");
|
||||
writePlistFile(tsxGrammar, file(Language.TypeScriptReact, Extension.TmLanguage));
|
||||
}
|
||||
|
||||
function changeTsToTsxTheme(theme: any) {
|
||||
const tsxUpdates = readYaml("../TypeScriptReact.YAML-tmTheme");
|
||||
const tsxUpdates = readYaml(file(Language.TypeScriptReact, Extension.YamlTmTheme));
|
||||
|
||||
// Update name, uuid
|
||||
for (let key in tsxUpdates) {
|
||||
|
@ -132,14 +148,14 @@ function changeTsToTsxTheme(theme: any) {
|
|||
}
|
||||
|
||||
function buildTheme() {
|
||||
const tsTheme = readYaml("../TypeScript.YAML-tmTheme");
|
||||
const tsTheme = readYaml(file(Language.TypeScript, Extension.YamlTmTheme));
|
||||
|
||||
// Write TypeScript.tmTheme
|
||||
writePlistFile(tsTheme, "../TypeScript.tmTheme");
|
||||
writePlistFile(tsTheme, file(Language.TypeScript, Extension.TmTheme));
|
||||
|
||||
// Write TypeScriptReact.thTheme
|
||||
const tsxTheme = changeTsToTsxTheme(tsTheme);
|
||||
writePlistFile(tsxTheme, "../TypeScriptReact.tmTheme");
|
||||
writePlistFile(tsxTheme, file(Language.TypeScriptReact, Extension.TmTheme));
|
||||
}
|
||||
|
||||
buildGrammar();
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"name": "build",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"main": "build.js",
|
||||
"scripts": {
|
||||
"postinstall": "npm start",
|
||||
"start": "tsc && node ./build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/js-yaml": "latest",
|
||||
"@types/node": "latest",
|
||||
"js-yaml": "latest",
|
||||
"plist": "latest",
|
||||
"typescript": "latest"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "typescript-tmlanguage",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom",
|
||||
"main": "build/build.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:grammar && npm run build:tests",
|
||||
"build:grammar": "tsc -p build && node build/build.js",
|
||||
"build:tests": "tsc -p tests",
|
||||
"pretest": "npm run build",
|
||||
"test": "mocha --full-trace tests/test.js",
|
||||
"diff": "cross-env-shell $DIFF tests/baselines tests/generated",
|
||||
"accept": "cpx tests/generated/* tests/baselines"
|
||||
},
|
||||
"dependencies": {
|
||||
"chai": "latest",
|
||||
"js-yaml": "latest",
|
||||
"mocha": "latest",
|
||||
"plist": "latest",
|
||||
"typescript": "latest",
|
||||
"vscode-textmate": "latest",
|
||||
"@types/chai": "latest",
|
||||
"@types/js-yaml": "latest",
|
||||
"@types/mocha": "latest",
|
||||
"@types/node": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cpx": "^1.5.0",
|
||||
"cross-env": "^5.1.1"
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"name": "tests",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "",
|
||||
"main": "test.ts",
|
||||
"scripts": {
|
||||
"pretest": "tsc -p ../build && node ../build/build.js && tsc",
|
||||
"test": "mocha --full-trace test.js",
|
||||
"diff": "cross-env-shell $DIFF baselines generated",
|
||||
"accept": "cpx generated/* baselines"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/chai": "latest",
|
||||
"@types/mocha": "latest",
|
||||
"@types/node": "latest",
|
||||
"chai": "latest",
|
||||
"mocha": "latest",
|
||||
"typescript": "latest",
|
||||
"vscode-textmate": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cpx": "^1.5.0",
|
||||
"cross-env": "^5.1.1"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче