update to meet newest standards
This commit is contained in:
35
ts/index.ts
35
ts/index.ts
@ -1,20 +1,25 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./projectinfo.plugins");
|
||||
import 'typings-global'
|
||||
import plugins = require('./projectinfo.plugins')
|
||||
|
||||
//npm
|
||||
import {ProjectinfoNpm} from "./projectinfo.classes.npm";
|
||||
export {ProjectinfoNpm} from "./projectinfo.classes.npm";
|
||||
export let npm = function(cwdArg,optionsArg){
|
||||
return new ProjectinfoNpm(cwdArg,optionsArg);
|
||||
};
|
||||
// direct access to classes
|
||||
export * from './projectinfo.classes.git'
|
||||
export * from './projectinfo.classes.npm'
|
||||
export * from './projectinfo.classes.projectinfo'
|
||||
|
||||
//quick functions
|
||||
export let getName = function(cwdArg){
|
||||
var localNpm = new ProjectinfoNpm(cwdArg);
|
||||
if (localNpm.status === "ok"){
|
||||
return localNpm.name;
|
||||
// npm
|
||||
import { ProjectinfoNpm } from './projectinfo.classes.npm'
|
||||
|
||||
// quick functions
|
||||
|
||||
/**
|
||||
* gets the name from package.json in a specified directory
|
||||
*/
|
||||
export let getNpmNameForDir = function(cwdArg){
|
||||
let localNpm = new ProjectinfoNpm(cwdArg)
|
||||
if (localNpm.status === 'ok') {
|
||||
return localNpm.name
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* TODO
|
||||
projectinfo.git = function(){
|
||||
@ -24,4 +29,4 @@ projectinfo.git = function(){
|
||||
projectinfo.mojo = function(){
|
||||
|
||||
};
|
||||
*/
|
||||
*/
|
||||
|
@ -1 +1,8 @@
|
||||
import "typings-global"
|
||||
import 'typings-global'
|
||||
|
||||
export class ProjectinfoGit {
|
||||
isGit: boolean
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
@ -1,28 +1,32 @@
|
||||
import "typings-global"
|
||||
import plugins = require("./projectinfo.plugins");
|
||||
export class ProjectinfoNpm {
|
||||
packageJson;
|
||||
name:string;
|
||||
version:string;
|
||||
status:string;
|
||||
license:string;
|
||||
git;
|
||||
|
||||
constructor(cwdArg:string,optionsArg:{gitAccessToken?:string} = {}){
|
||||
this.packageJson = plugins.smartfile.fs.toObjectSync(
|
||||
plugins.path.join(
|
||||
plugins.path.resolve(cwdArg),
|
||||
"package.json"
|
||||
),
|
||||
"json"
|
||||
);
|
||||
this.name = this.packageJson.name;
|
||||
this.version = this.packageJson.version;
|
||||
this.status = "ok";
|
||||
this.license = this.packageJson.license;
|
||||
if (this.packageJson.repository){
|
||||
this.git = new plugins.smartstring.GitRepo(this.packageJson.repository.url,optionsArg.gitAccessToken);
|
||||
};
|
||||
import 'typings-global'
|
||||
import plugins = require('./projectinfo.plugins')
|
||||
export class ProjectinfoNpm {
|
||||
isNpm: boolean = false
|
||||
packageJson: any
|
||||
name: string
|
||||
version: string
|
||||
status: string
|
||||
license: string
|
||||
git
|
||||
|
||||
constructor(cwdArg: string, optionsArg: { gitAccessToken?: string } = {}) {
|
||||
let resolvedCwd = plugins.path.resolve(cwdArg)
|
||||
if (plugins.smartfile.fs.fileExists(plugins.path.join(resolvedCwd, 'package.json'))) {
|
||||
this.isNpm = true
|
||||
this.packageJson = plugins.smartfile.fs.toObjectSync(
|
||||
plugins.path.join(
|
||||
resolvedCwd,
|
||||
'package.json'
|
||||
),
|
||||
'json'
|
||||
)
|
||||
this.name = this.packageJson.name
|
||||
this.version = this.packageJson.version
|
||||
this.status = 'ok'
|
||||
this.license = this.packageJson.license
|
||||
if (this.packageJson.repository) {
|
||||
this.git = new plugins.smartstring.GitRepo(this.packageJson.repository.url, optionsArg.gitAccessToken)
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
21
ts/projectinfo.classes.projectinfo.ts
Normal file
21
ts/projectinfo.classes.projectinfo.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import * as plugins from './projectinfo.plugins'
|
||||
import { ProjectinfoNpm } from './projectinfo.classes.npm'
|
||||
|
||||
export type TProjectType = 'git' | 'npm'
|
||||
|
||||
/**
|
||||
* class projectinfo automatically examines a given directory and exposes relevant info about it
|
||||
*/
|
||||
export class ProjectInfo {
|
||||
type: TProjectType
|
||||
npm: ProjectinfoNpm
|
||||
/**
|
||||
* this constructor
|
||||
*/
|
||||
constructor(cwdArg: string) {
|
||||
this.npm = new ProjectinfoNpm(cwdArg)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import "typings-global"
|
||||
export let path = require("path");
|
||||
export let Q = require("q");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
||||
import 'typings-global'
|
||||
export let path = require('path')
|
||||
export let Q = require('q')
|
||||
export import smartfile = require('smartfile')
|
||||
export import smartstring = require('smartstring')
|
||||
|
Reference in New Issue
Block a user