Skip to content

Replace grunt-tslint with direct calling to tslint #2954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var now = new Date().toISOString();
const childProcess = require("child_process");
const now = new Date().toISOString();

function shallowCopy(obj) {
var result = {};
Object.keys(obj).forEach(function(key) {
Object.keys(obj).forEach(function (key) {
result[key] = obj[key];
});
return result;
Expand All @@ -11,10 +12,10 @@ function shallowCopy(obj) {
var travis = process.env["TRAVIS"];
var buildNumber = process.env["PACKAGE_VERSION"] || process.env["BUILD_NUMBER"] || "non-ci";

module.exports = function(grunt) {
module.exports = function (grunt) {
var path = require("path");
var commonLibNodeModules = path.join("lib", "common", "node_modules");
if(require("fs").existsSync(commonLibNodeModules)) {
if (require("fs").existsSync(commonLibNodeModules)) {
grunt.file.delete(commonLibNodeModules);
}
grunt.file.write(path.join("lib", "common", ".d.ts"), "");
Expand Down Expand Up @@ -50,17 +51,6 @@ module.exports = function(grunt) {
},
},

tslint: {
build: {
files: {
src: ["lib/**/*.ts", "test/**/*.ts", "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts", "lib/common/test/unit-tests/**/*.ts", "definitions/**/*.ts", "!lib/**/*.d.ts" , "!test/**/*.d.ts"]
},
options: {
configuration: grunt.file.readJSON("./tslint.json")
}
}
},

watch: {
devall: {
files: ["lib/**/*.ts", 'test/**/*.ts', "!lib/common/node_modules/**/*.ts", "!lib/common/messages/**/*.ts"],
Expand Down Expand Up @@ -96,7 +86,7 @@ module.exports = function(grunt) {
command: "npm pack",
options: {
execOptions: {
env: (function() {
env: (function () {
var env = shallowCopy(process.env);
env["NATIVESCRIPT_SKIP_POSTINSTALL_TASKS"] = "1";
return env;
Expand Down Expand Up @@ -145,7 +135,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-ts");
grunt.loadNpmTasks("grunt-tslint");

grunt.registerTask("set_package_version", function(version) {
grunt.registerTask("set_package_version", function (version) {
var buildVersion = version !== undefined ? version : buildNumber;
if (process.env["BUILD_CAUSE_GHPRBCAUSE"]) {
buildVersion = "PR" + buildVersion;
Expand All @@ -154,16 +144,20 @@ module.exports = function(grunt) {
var packageJson = grunt.file.readJSON("package.json");
var versionParts = packageJson.version.split("-");
if (process.env["RELEASE_BUILD"]) {
// HACK - excluded until 1.0.0 release or we refactor our project infrastructure (whichever comes first)
// packageJson.version = versionParts[0];
// HACK - excluded until 1.0.0 release or we refactor our project infrastructure (whichever comes first)
// packageJson.version = versionParts[0];
} else {
versionParts[1] = buildVersion;
packageJson.version = versionParts.join("-");
}
grunt.file.write("package.json", JSON.stringify(packageJson, null, " "));
});

grunt.registerTask("enableScripts", function(enable) {
grunt.registerTask("tslint:build", function (version) {
childProcess.execSync("npm run tslint", { stdio: "inherit" });
});

grunt.registerTask("enableScripts", function (enable) {
var enableTester = /false/i;
var newScriptsAttr = !enableTester.test(enable) ? "scripts" : "skippedScripts";
var packageJson = grunt.file.readJSON("package.json");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"preuninstall": "node preuninstall.js",
"mocha": "node test-scripts/mocha.js",
"tsc": "tsc",
"tslint": "tslint -p tsconfig.json --type-check",
"test-watch": "node ./dev/tsc-to-mocha-watch.js"
},
"repository": {
Expand Down Expand Up @@ -97,7 +98,6 @@
"grunt-contrib-watch": "1.0.0",
"grunt-shell": "1.3.0",
"grunt-ts": "6.0.0-beta.16",
"grunt-tslint": "5.0.1",
"istanbul": "0.4.5",
"mocha": "3.1.2",
"should": "7.0.2",
Expand Down
48 changes: 24 additions & 24 deletions test/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,30 +245,6 @@ export class ProjectDataStub implements IProjectData {
}
}

export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
public platformsNames: string[];

public getPlatformData(platform: string, projectData: IProjectData): IPlatformData {
return {
frameworkPackageName: "",
platformProjectService: new PlatformProjectServiceStub(),
emulatorServices: undefined,
projectRoot: "",
normalizedPlatformName: "",
appDestinationDirectoryPath: "",
deviceBuildOutputPath: "",
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
frameworkFilesExtensions: [],
relativeToFrameworkConfigurationFilePath: "",
fastLivesyncFileExtensions: []
};
}

public get availablePlatforms(): any {
return undefined;
}
}

export class PlatformProjectServiceStub extends EventEmitter implements IPlatformProjectService {
getPlatformData(projectData: IProjectData): IPlatformData {
return {
Expand Down Expand Up @@ -362,6 +338,30 @@ export class PlatformProjectServiceStub extends EventEmitter implements IPlatfor
}
}

export class PlatformsDataStub extends EventEmitter implements IPlatformsData {
public platformsNames: string[];

public getPlatformData(platform: string, projectData: IProjectData): IPlatformData {
return {
frameworkPackageName: "",
platformProjectService: new PlatformProjectServiceStub(),
emulatorServices: undefined,
projectRoot: "",
normalizedPlatformName: "",
appDestinationDirectoryPath: "",
deviceBuildOutputPath: "",
getValidPackageNames: (buildOptions: { isForDevice?: boolean, isReleaseBuild?: boolean }) => [],
frameworkFilesExtensions: [],
relativeToFrameworkConfigurationFilePath: "",
fastLivesyncFileExtensions: []
};
}

public get availablePlatforms(): any {
return undefined;
}
}

export class ProjectDataService implements IProjectDataService {
getNSValue(propertyName: string): any {
return {};
Expand Down