mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Merge branch 'ErjanGavalji/add-sha-info'
This commit is contained in:
51
gruntfile.js
51
gruntfile.js
@ -23,6 +23,9 @@ module.exports = function(grunt) {
|
|||||||
var updateModulesPackageDef = function(content, srcPath) {
|
var updateModulesPackageDef = function(content, srcPath) {
|
||||||
return updatePackageDef(content, function(contentAsObject) {
|
return updatePackageDef(content, function(contentAsObject) {
|
||||||
contentAsObject.version = localCfg.packageVersion;
|
contentAsObject.version = localCfg.packageVersion;
|
||||||
|
if (localCfg.commitSHA) {
|
||||||
|
contentAsObject.repository.url += "/commit/" + localCfg.commitSHA;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,6 +36,15 @@ module.exports = function(grunt) {
|
|||||||
contentAsObject.name = "tns-samples-" + currentAppName;
|
contentAsObject.name = "tns-samples-" + currentAppName;
|
||||||
contentAsObject.description = "Nativescript " + currentAppName + " sample application";
|
contentAsObject.description = "Nativescript " + currentAppName + " sample application";
|
||||||
contentAsObject.license = "BSD";
|
contentAsObject.license = "BSD";
|
||||||
|
if (!contentAsObject.repository) {
|
||||||
|
contentAsObject.repository = {};
|
||||||
|
}
|
||||||
|
if (!contentAsObject.repository.url) {
|
||||||
|
contentAsObject.repository.url = localCfg.mainPackageContent.repository.url;
|
||||||
|
}
|
||||||
|
if (localCfg.commitSHA) {
|
||||||
|
contentAsObject.repository.url += "/commit/" + localCfg.commitSHA;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -42,16 +54,32 @@ module.exports = function(grunt) {
|
|||||||
contentAsObject.name = "tns-definitions";
|
contentAsObject.name = "tns-definitions";
|
||||||
contentAsObject.description = "NativeScript Module definitions";
|
contentAsObject.description = "NativeScript Module definitions";
|
||||||
contentAsObject.license = "Apache-2.0";
|
contentAsObject.license = "Apache-2.0";
|
||||||
});
|
if (localCfg.commitSHA) {
|
||||||
|
contentAsObject.repository.url += "/commit/" + localCfg.commitSHA;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var getPackageVersion = function(packageFilePath) {
|
var getCommitSha = function() {
|
||||||
packageContent = grunt.file.readJSON(packageFilePath);
|
if (process.env.GIT_COMMIT) {
|
||||||
|
return process.env.GIT_COMMIT;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
|
var assignGitSHA = function(err, stdout, stderr, cb) {
|
||||||
|
if (!localCfg.commitSHA) {
|
||||||
|
localCfg.commitSHA = stdout.replace("\n", "");
|
||||||
|
}
|
||||||
|
cb();
|
||||||
|
};
|
||||||
|
|
||||||
|
var getPackageVersion = function() {
|
||||||
var buildVersion = process.env.PACKAGE_VERSION;
|
var buildVersion = process.env.PACKAGE_VERSION;
|
||||||
if (!buildVersion) {
|
if (!buildVersion) {
|
||||||
return packageContent.version;
|
return localCfg.mainPackageContent.version;
|
||||||
}
|
}
|
||||||
return packageContent.version + "-" + buildVersion;
|
return localCfg.mainPackageContent.version + "-" + buildVersion;
|
||||||
};
|
};
|
||||||
|
|
||||||
var processAppFile = function(content, srcPath) {
|
var processAppFile = function(content, srcPath) {
|
||||||
@ -88,7 +116,10 @@ module.exports = function(grunt) {
|
|||||||
"!./ui/slide-out/**/*.*"
|
"!./ui/slide-out/**/*.*"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
localCfg.mainPackageContent = grunt.file.readJSON(localCfg.packageJsonFilePath);
|
||||||
localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
|
localCfg.packageVersion = getPackageVersion(localCfg.packageJsonFilePath);
|
||||||
|
localCfg.commitSHA = getCommitSha();
|
||||||
localCfg.defaultExcludes = [
|
localCfg.defaultExcludes = [
|
||||||
"!" + localCfg.outDir + "/**/*.*",
|
"!" + localCfg.outDir + "/**/*.*",
|
||||||
"!./node_modules/**/*.*",
|
"!./node_modules/**/*.*",
|
||||||
@ -283,6 +314,14 @@ module.exports = function(grunt) {
|
|||||||
return targetDirs;
|
return targetDirs;
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
shell: {
|
||||||
|
getGitSHA: {
|
||||||
|
command: "git rev-parse HEAD",
|
||||||
|
options: {
|
||||||
|
callback: assignGitSHA
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -292,6 +331,7 @@ module.exports = function(grunt) {
|
|||||||
grunt.loadNpmTasks("grunt-exec");
|
grunt.loadNpmTasks("grunt-exec");
|
||||||
grunt.loadNpmTasks("grunt-tslint");
|
grunt.loadNpmTasks("grunt-tslint");
|
||||||
grunt.loadNpmTasks("grunt-multi-dest");
|
grunt.loadNpmTasks("grunt-multi-dest");
|
||||||
|
grunt.loadNpmTasks("grunt-shell");
|
||||||
|
|
||||||
var cloneTasks = function(originalTasks, taskNameSuffix)
|
var cloneTasks = function(originalTasks, taskNameSuffix)
|
||||||
{
|
{
|
||||||
@ -403,6 +443,7 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
grunt.registerTask("default", ((typeof(grunt.option('runtslint')) != "undefined" && !grunt.option('runtslint')) ? [] : ["tslint:build"]).concat([
|
||||||
"clean:build",
|
"clean:build",
|
||||||
|
"shell:getGitSHA",
|
||||||
|
|
||||||
"collect-apps-raw-files",
|
"collect-apps-raw-files",
|
||||||
"collect-definitions-raw-files",
|
"collect-definitions-raw-files",
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
"name": "tns-core",
|
"name": "tns-core",
|
||||||
"description": "Telerik NativeScript Core",
|
"description": "Telerik NativeScript Core",
|
||||||
"version": "0.4.2",
|
"version": "0.4.2",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/NativeScript/cross-platform-modules"
|
||||||
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"**/*.*",
|
"**/*.*",
|
||||||
"**/*"
|
"**/*"
|
||||||
@ -13,6 +17,7 @@
|
|||||||
"grunt-contrib-copy": "0.5.0",
|
"grunt-contrib-copy": "0.5.0",
|
||||||
"grunt-exec": "0.4.5",
|
"grunt-exec": "0.4.5",
|
||||||
"grunt-multi-dest": "1.0.0",
|
"grunt-multi-dest": "1.0.0",
|
||||||
|
"grunt-shell": "1.1.2",
|
||||||
"grunt-ts": "1.12.1",
|
"grunt-ts": "1.12.1",
|
||||||
"grunt-tslint": "0.4.2",
|
"grunt-tslint": "0.4.2",
|
||||||
"typescript": "1.4.1"
|
"typescript": "1.4.1"
|
||||||
|
Reference in New Issue
Block a user