Removing the redundant files which are already organized in different directories according to their use and purpose. (#7)

This commit is contained in:
manpatel3107 2019-01-03 15:21:50 -08:00 коммит произвёл GitHub
Родитель 66de59674c
Коммит e1a69a6709
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 0 добавлений и 181 удалений

Просмотреть файл

@ -1,22 +0,0 @@
const ExtensionConstants = {
mezzuritePath : '/node_modules/@microsoft/',
mezzuriteDirectories : ["mezzurite-angular", "mezzurite-react", "mezzurite-angularjs"],
mezzuriteFrameworks : ["@microsoft/mezzurite-angular", "@microsoft/mezzurite-react", "@microsoft/mezzurite-angularjs"],
pathForAppsPackageJson : "**/package.json",
pathForNodeModules : "**/node_modules/**",
titleForWelcomePage : "Mezzurite Extension",
placeholderForStyleTag : "##StyleLink##",
webviewStyleName : "style.css",
webviewHtmlFileName : "landingPage.html",
clientFolderName : "client",
validateMezzuriteCommand : "extension.validateMezzurite",
displayLandingPageCommand : "extension.displayLandingPage",
mezzuriteAngularJs:"@microsoft/mezzurite-angularjs",
mezzuriteAngular:"@microsoft/mezzurite-angular",
mezzuriteReact:"@microsoft/mezzurite-react",
}
export { ExtensionConstants };

Просмотреть файл

@ -1,114 +0,0 @@
import {workspace} from 'vscode';
import ts = require('typescript');
import 'reflect-metadata';
import {MezzuriteUtils} from './mezzurite-utils';
export class MezzuriteAngularV1{
constructor(){
}
async executeFrameworkSpecificRules(){
// Read the .js and .ts files from the work space
// Get the contents
// Look for @Component keyword
// If found, get that object
// Check property templateUrl and template
// If templateUrl found store that file name as html
// If template found, mark that as component and check for mezzurite and component title in that html string
let files: any = await MezzuriteUtils.searchWorkspace(workspace, "**/*.ts", "**/node_modules/**");
let data: string;
let htmlFiles: any = [];
let output : any = [];
for(const index in files){
data = MezzuriteUtils.readFileFromWorkspace(files[index].fsPath, 'utf8');
if(data.indexOf('@NgModule') > -1){
console.log("This is a angular module:-"+ files[index].fsPath);
console.log("You should have import and router.start() here");
}
if(data.indexOf('@Component') > -1){
let outputObject: any = {
componentName: "",
filePath: "",
status: "Unmarked",
template: ""
};
// Add the file path
outputObject.filePath = files[index].fsPath;
const parsedData = ts.createSourceFile(files[index].fsPath, data, ts.ScriptTarget.Latest, true);
var componentFound = false;
for(var i = 0;i < parsedData.statements.length; i++){
var nodeObj: any = ts.getParseTreeNode(parsedData.statements[i]);
if(nodeObj.decorators && ts.isDecorator(nodeObj.decorators[0])){
// Add the componentName
outputObject.componentName = nodeObj.name.text;
// Get the decorator properties
var expObj = ts.getParseTreeNode(nodeObj.decorators[0].expression);
if(expObj.expression.text !== "Component"){
continue;
}
var properties;
if(expObj && expObj.arguments){
properties = ts.getParseTreeNode(expObj.arguments[0]).properties;
componentFound = true;
}
for(var j = 0; j < properties.length; j++){
var element = properties[j];
if(element.name.text === "templateUrl"){
htmlFiles.push(element.initializer.text);
outputObject.template = element.initializer.text;
if(element.initializer.text !== ""){
var found = await MezzuriteAngularV1.parseHTMLFile(element.initializer.text);
if(found){
outputObject.status = "Marked";
}
}
}
if(element.name.text === "template"){
outputObject.template = "Html template provided";
if(MezzuriteAngularV1.verifyComponentMarking(element.initializer.text)){
outputObject.status = "Marked";
}
}
};
}
}
if(componentFound){
output.push(outputObject);
}
}
}
// Display output
for(var component = 0;component < output.length; component++){
console.log(output[component]);
}
}
static async parseHTMLFile(filePath: string){
var lastIndex = filePath.lastIndexOf('/') > -1? filePath.lastIndexOf('/') : filePath.lastIndexOf('\\');
var includePattern = "**/" + filePath.substring(lastIndex + 1, filePath.length);
// Get the html file and parse its contents for mezzurite markings
let files: any = await MezzuriteUtils.searchWorkspace(workspace, includePattern, "**/node_modules/**");
var templateString = MezzuriteUtils.readFileFromWorkspace(files[0].fsPath, 'utf8');
return MezzuriteAngularV1.verifyComponentMarking(templateString);
}
static verifyComponentMarking(htmlString: string){
if(htmlString.indexOf('mezzurite') > -1 && htmlString.indexOf('component-title')> -1){
return true;
}
return false;
}
}

Просмотреть файл

@ -1,45 +0,0 @@
import * as fs from "fs";
export class MezzuriteUtils {
constructor(
) { }
/**
* This method search for Mezzurite-framework dependency in node_modules/mezzurite-framework's Package.json file
* @param workspace is the current workspace in the vs code editor
* @param includePatterns is the path pattern which needs to searched
* @param excludePattern is the path pattern which should be excluded from search
* @return Return the arrays of files found in the current workspace
*/
static async searchWorkspace(workspace: any, includePatterns: any, excludePattern: any){
try{
return await workspace.findFiles(includePatterns, excludePattern);
}catch(err){
console.log(err);
throw err;
}
}
/**
* This method reads file contents, provided the filePath
* @param filePath is the path to the file
* @param encodingType is the character encoding type
* @return Returns the file contents
*/
static readFileFromWorkspace(filePath: string, encodingType: string){
let data: any;
try{
data = fs.readFileSync(filePath, encodingType);
}
catch(err)
{
if (err){
console.log('File not found at the following path:-' + filePath);
throw err;
}
}
return data;
}
}