26 Commits

Author SHA1 Message Date
8c4404ff68 5.0.1 2022-04-18 22:17:11 +02:00
f2e91b8e1b fix(core): update 2022-04-18 22:17:10 +02:00
31bcc5f8c2 5.0.0 2022-04-18 22:16:46 +02:00
216eabe035 BREAKING CHANGE(core): switch to ESM 2022-04-18 22:16:46 +02:00
bc79a9ae42 4.0.5 2020-06-01 22:57:09 +00:00
b82b6de5f5 fix(core): update 2020-06-01 22:57:08 +00:00
b27c069177 4.0.4 2020-06-01 22:45:54 +00:00
b25be551f6 fix(core): update 2020-06-01 22:45:54 +00:00
47da0afd4b 4.0.3 2020-06-01 22:45:46 +00:00
f9296f1f26 fix(core): update 2020-06-01 22:45:45 +00:00
d013fbad50 4.0.2 2018-09-02 14:24:45 +02:00
d5f72a76d9 fix(package.json): fix private param 2018-09-02 14:24:45 +02:00
d26a8b02db 4.0.1 2018-09-02 14:21:05 +02:00
9b3db5daca fix(ci): update 2018-09-02 14:21:05 +02:00
75d94111a9 4.0.0 2018-09-02 14:12:36 +02:00
4f425dfc93 BREAKING CHANGE(scope): change scope 2018-09-02 14:12:36 +02:00
0f2af7219e 3.0.5 2018-09-02 14:08:15 +02:00
9abe15f871 fix(dependencies): update 2018-09-02 14:08:15 +02:00
27aa9f7166 3.0.4 2017-09-22 23:53:26 +02:00
0a1063e6c8 update ci 2017-09-22 23:52:28 +02:00
f606dd6e6d 3.0.3 2017-09-22 23:46:46 +02:00
5c608dd675 update dependencies 2017-09-22 23:46:43 +02:00
b4f8093230 3.0.2 2017-02-27 22:46:15 +01:00
aa903ec93e update deps and readme 2017-02-27 22:46:12 +01:00
187721a511 3.0.1 2016-11-27 00:09:09 +01:00
c457cbff6a update README 2016-11-27 00:09:04 +01:00
31 changed files with 18692 additions and 395 deletions

23
.gitignore vendored
View File

@ -1,9 +1,20 @@
.nogit/
# artifacts
coverage/
docs/
public/
pages/
# installs
node_modules/
pages/
public
ts/**/*.js
ts/**/*.js.map
ts/typings/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,59 +1,140 @@
image: hosttoday/ht-docker-node:npmts
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
testLTS:
stage: test
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci test lts
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
testSTABLE:
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
stage: metadata
script:
- npmci command npmpage --host gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,16 +0,0 @@
# projectinfo
returns a projectoinfo object for a directory path. TypeScript ready.
## Status
[![build status](https://gitlab.com/pushrocks/projectinfo/badges/master/build.svg)](https://gitlab.com/pushrocks/projectinfo/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/projectinfo.svg)](https://david-dm.org/pushrocks/projectinfo)
[![devDependency Status](https://david-dm.org/pushrocks/projectinfo/dev-status.svg)](https://david-dm.org/pushrocks/projectinfo#info=devDependencies)
## Usage
```TypeScript
var projectinfo = require("projectinfo")
myProject = new ProjectinfoNpm("/somepath/to/projectroot");
myProject.version // displays version
```

8
dist/index.d.ts vendored
View File

@ -1,8 +0,0 @@
import 'typings-global';
export * from './projectinfo.classes.git';
export * from './projectinfo.classes.npm';
export * from './projectinfo.classes.projectinfo';
/**
* gets the name from package.json in a specified directory
*/
export declare let getNpmNameForDir: (cwdArg: any) => string;

31
dist/index.js vendored
View File

@ -1,31 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
require("typings-global");
// direct access to classes
__export(require("./projectinfo.classes.git"));
__export(require("./projectinfo.classes.npm"));
__export(require("./projectinfo.classes.projectinfo"));
// npm
const projectinfo_classes_npm_1 = require("./projectinfo.classes.npm");
// quick functions
/**
* gets the name from package.json in a specified directory
*/
exports.getNpmNameForDir = function (cwdArg) {
let localNpm = new projectinfo_classes_npm_1.ProjectinfoNpm(cwdArg);
if (localNpm.status === 'ok') {
return localNpm.name;
}
};
/* TODO
projectinfo.git = function(){
};
projectinfo.mojo = function(){
};
*/
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsMEJBQXVCO0FBR3ZCLDJCQUEyQjtBQUMzQiwrQ0FBeUM7QUFDekMsK0NBQXlDO0FBQ3pDLHVEQUFpRDtBQUVqRCxNQUFNO0FBQ04sdUVBQTBEO0FBRTFELGtCQUFrQjtBQUVsQjs7R0FFRztBQUNRLFFBQUEsZ0JBQWdCLEdBQUcsVUFBUyxNQUFNO0lBQ3pDLElBQUksUUFBUSxHQUFHLElBQUksd0NBQWMsQ0FBQyxNQUFNLENBQUMsQ0FBQTtJQUN6QyxFQUFFLENBQUMsQ0FBQyxRQUFRLENBQUMsTUFBTSxLQUFLLElBQUksQ0FBQyxDQUFDLENBQUM7UUFDM0IsTUFBTSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUE7SUFDeEIsQ0FBQztBQUNMLENBQUMsQ0FBQTtBQUVEOzs7Ozs7OztFQVFFIn0=

View File

@ -1,16 +0,0 @@
export declare class ProjectinfoGit {
isGit: boolean;
githost: string;
gituser: string;
gitrepo: string;
cwd: string;
constructor(cwdArg: string);
/**
* get git info from path
*/
getGitInfoFromPath(): void;
/**
* get git info from remote url
*/
getGitInfoFromRemote(remoteUrlArg: string): void;
}

View File

@ -1,24 +0,0 @@
"use strict";
const plugins = require("./projectinfo.plugins");
class ProjectinfoGit {
constructor(cwdArg) {
this.cwd = cwdArg;
this.getGitInfoFromPath();
}
/**
* get git info from path
*/
getGitInfoFromPath() {
let localSmartpath = new plugins.smartpath.Smartpath(this.cwd);
this.gitrepo = localSmartpath.pathLevelsBackwards[0];
this.gituser = localSmartpath.pathLevelsBackwards[1];
}
/**
* get git info from remote url
*/
getGitInfoFromRemote(remoteUrlArg) {
let gitRepoParsed = new plugins.smartstring.GitRepo(remoteUrlArg);
}
}
exports.ProjectinfoGit = ProjectinfoGit;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8uY2xhc3Nlcy5naXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wcm9qZWN0aW5mby5jbGFzc2VzLmdpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsaURBQWdEO0FBRWhEO0lBTUksWUFBWSxNQUFjO1FBQ3RCLElBQUksQ0FBQyxHQUFHLEdBQUcsTUFBTSxDQUFBO1FBQ2pCLElBQUksQ0FBQyxrQkFBa0IsRUFBRSxDQUFBO0lBQzdCLENBQUM7SUFFRDs7T0FFRztJQUNILGtCQUFrQjtRQUNkLElBQUksY0FBYyxHQUFHLElBQUksT0FBTyxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1FBQzlELElBQUksQ0FBQyxPQUFPLEdBQUcsY0FBYyxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQyxDQUFBO1FBQ3BELElBQUksQ0FBQyxPQUFPLEdBQUcsY0FBYyxDQUFDLG1CQUFtQixDQUFDLENBQUMsQ0FBQyxDQUFBO0lBQ3hELENBQUM7SUFFRDs7T0FFRztJQUNILG9CQUFvQixDQUFDLFlBQW9CO1FBQ3JDLElBQUksYUFBYSxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUE7SUFDckUsQ0FBQztDQUNKO0FBMUJELHdDQTBCQyJ9

View File

@ -1,14 +0,0 @@
import 'typings-global';
import plugins = require('./projectinfo.plugins');
export declare class ProjectinfoNpm {
isNpm: boolean;
packageJson: any;
name: string;
version: string;
status: string;
license: string;
git: plugins.smartstring.GitRepo;
constructor(cwdArg: string, optionsArg?: {
gitAccessToken?: string;
});
}

View File

@ -1,24 +0,0 @@
"use strict";
require("typings-global");
const plugins = require("./projectinfo.plugins");
class ProjectinfoNpm {
constructor(cwdArg, optionsArg = {}) {
this.isNpm = false;
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);
}
;
}
}
;
}
exports.ProjectinfoNpm = ProjectinfoNpm;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8uY2xhc3Nlcy5ucG0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wcm9qZWN0aW5mby5jbGFzc2VzLm5wbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLGlEQUFpRDtBQUNqRDtJQVNJLFlBQVksTUFBYyxFQUFFLGFBQTBDLEVBQUU7UUFSeEUsVUFBSyxHQUFZLEtBQUssQ0FBQTtRQVNsQixJQUFJLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUM5QyxFQUFFLENBQUMsQ0FBQyxPQUFPLEN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ectinfoGit } from './projectinfo.classes.git';
export declare type TProjectType = 'git' | 'npm';
/**
* class projectinfo automatically examines a given directory and exposes relevant info about it
*/
export declare class ProjectInfo {
type: TProjectType;
npm: ProjectinfoNpm;
git: ProjectinfoGit;
/**
* constructor of class ProjectInfo
*/
constructor(cwdArg: string);
}

View File

@ -1,17 +0,0 @@
"use strict";
const projectinfo_classes_npm_1 = require("./projectinfo.classes.npm");
const projectinfo_classes_git_1 = require("./projectinfo.classes.git");
/**
* class projectinfo automatically examines a given directory and exposes relevant info about it
*/
class ProjectInfo {
/**
* constructor of class ProjectInfo
*/
constructor(cwdArg) {
this.npm = new projectinfo_classes_npm_1.ProjectinfoNpm(cwdArg);
this.git = new projectinfo_classes_git_1.ProjectinfoGit(cwdArg);
}
}
exports.ProjectInfo = ProjectInfo;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8uY2xhc3Nlcy5wcm9qZWN0aW5mby5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Byb2plY3RpbmZvLmNsYXNzZXMucHJvamVjdGluZm8udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLHVFQUEwRDtBQUMxRCx1RUFBMEQ7QUFHMUQ7O0dBRUc7QUFDSDtJQUlJOztPQUVHO0lBQ0gsWUFBWSxNQUFjO1FBQ3RCLElBQUksQ0FBQyxHQUFHLEdBQUcsSUFBSSx3Q0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO1FBQ3JDLElBQUksQ0FBQyxHQUFHLEdBQUcsSUFBSSx3Q0FBYyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3pDLENBQUM7Q0FDSjtBQVhELGtDQVdDIn0=

View File

@ -1,6 +0,0 @@
import 'typings-global';
export import path = require('path');
export import q = require('q');
export import smartfile = require('smartfile');
export import smartstring = require('smartstring');
export import smartpath = require('smartpath');

View File

@ -1,8 +0,0 @@
"use strict";
require("typings-global");
exports.path = require("path");
exports.q = require("q");
exports.smartfile = require("smartfile");
exports.smartstring = require("smartstring");
exports.smartpath = require("smartpath");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Byb2plY3RpbmZvLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2QiwrQkFBb0M7QUFDcEMseUJBQThCO0FBQzlCLHlDQUE4QztBQUM5Qyw2Q0FBa0Q7QUFDbEQseUNBQThDIn0=

View File

@ -1,11 +1,17 @@
{
"npmts": {
"mode": "default",
"coverageTreshold": 80
},
"npmci": {
"globalNpmTools": [
"npmts"
]
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "projectinfo",
"description": "gather information about projects. supports npm, git etc.",
"npmPackagename": "@pushrocks/projectinfo",
"license": "MIT"
}
}
}
}

18314
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,14 @@
{
"name": "projectinfo",
"version": "3.0.0",
"name": "@pushrocks/projectinfo",
"version": "5.0.1",
"private": false,
"description": "gather information about projects. supports npm, git etc.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web --allowimplicitany)"
},
"repository": {
"type": "git",
@ -25,16 +28,33 @@
},
"homepage": "https://gitlab.com/pushrocks/projectinfo#readme",
"devDependencies": {
"npmts-g": "^5.2.10",
"should": "^11.1.1",
"typings-test": "^1.0.3"
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsrun": "^1.2.32",
"@gitzone/tstest": "^1.0.70",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.25",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@types/q": "0.0.32",
"q": "^1.4.1",
"smartfile": "4.1.0",
"smartpath": "^3.2.6",
"smartstring": "2.0.22",
"typings-global": "^1.0.14"
}
"@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartstring": "^4.0.2"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

51
readme.md Normal file
View File

@ -0,0 +1,51 @@
# @pushrocks/projectinfo
gather information about projects. supports npm, git etc.
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/projectinfo)
* [gitlab.com (source)](https://gitlab.com/pushrocks/projectinfo)
* [github.com (source mirror)](https://github.com/pushrocks/projectinfo)
* [docs (typedoc)](https://pushrocks.gitlab.io/projectinfo/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/projectinfo/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/projectinfo/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/projectinfo)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/projectinfo)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/projectinfo)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/projectinfo)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/projectinfo)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import { ProjectInfo } from 'projectinfo';
let myProjectInfo = new ProjectInfo('/some/path/to/proejct');
let npmName = myProjectInfo.npm.name; // returns npm name from package.json
let npmVersion = myProjectInfo.npm.version; // returns version from package.json
let gitRepo = myProjectInfo.git.gitrepo; // returns the name of the gitrepo
let gitRemotes = myProjectInfo.git.remotes; // returns array with registered remotes
// for more info check out the module in your IDE with TypeScript intellisense enabled
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -2,6 +2,7 @@
"name": "testpackage",
"version": "1.0.0",
"description": "some test",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/someuser/somerepo.git"

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,33 +0,0 @@
"use strict";
require("typings-test");
const projectinfo = require("../dist/index");
let should = require('should');
let path = require('path');
let testBasePath = path.resolve(__dirname);
describe('projectinfo', function () {
describe('.npm() return', function () {
let myNpm = new projectinfo.ProjectinfoNpm(testBasePath, { gitAccessToken: 'sometoken' });
it('should have .packageJson', function () {
should(myNpm.packageJson).have.property('version', '1.0.0');
should(myNpm.packageJson).have.property('name', 'testpackage');
});
it('should have .version', function () {
should(myNpm).have.property('version', '1.0.0');
});
it('should have .name', function () {
should(myNpm).have.property('name', 'testpackage');
});
it('should have .license', function () {
should(myNpm).have.property('license', 'MIT');
});
it('should have .git', function () {
should(myNpm.git.httpsUrl).equal('https://sometoken@github.com/someuser/somerepo.git');
});
});
describe('.getNpmNameForDir()', function () {
it('should return a name', function () {
should(projectinfo.getNpmNameForDir(testBasePath)).equal('testpackage');
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0FBQzlCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtBQUMxQixJQUFJLFlBQVksR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBRTFDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLEtBQUssR0FBRyxJQUFJLFdBQVcsQ0FBQyxjQUFjLENBQUMsWUFBWSxFQUFDLEVBQUMsY0FBYyxFQUFFLFdBQVcsRUFBQyxDQUFDLENBQUE7UUFDdEYsRUFBRSxDQUFDLDBCQUEwQixFQUFDO1lBQzFCLE1BQU0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AAE,CAAC,sBAAsB,EAAC;YACtB,KAAK;iBACA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAC,KAAK,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,kBAAkB,EAAC;YAClB,KAAK,CAAC,GAAG,CAAC,QAAQ;iBACb,MAAM,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;QAC5E,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,YAAY,EAAC;QAClB,EAAE,CAAC,sBAAsB,EAAC;YACtB,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC;iBAC5B,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}

View File

@ -1,38 +1,32 @@
import 'typings-test'
import projectinfo = require('../dist/index')
let should = require('should')
let path = require('path')
let testBasePath = path.resolve(__dirname)
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartpath from '@pushrocks/smartpath';
import * as projectinfo from '../ts/index.js';
describe('projectinfo',function(){
describe('.npm() return',function(){
let myNpm = new projectinfo.ProjectinfoNpm(testBasePath,{gitAccessToken: 'sometoken'})
it('should have .packageJson',function(){
should(myNpm.packageJson).have.property('version','1.0.0')
should(myNpm.packageJson).have.property('name','testpackage')
})
import * as path from 'path';
let testBasePath = path.resolve(smartpath.get.dirnameFromImportMetaUrl(import.meta.url));
it('should have .version',function(){
should(myNpm).have.property('version','1.0.0')
})
let myNpm = new projectinfo.ProjectinfoNpm(testBasePath, { gitAccessToken: 'sometoken' });
tap.test('should have .packageJson', async () => {
expect(myNpm.packageJson).property('version').toEqual('1.0.0');
expect(myNpm.packageJson).property('name').toEqual('testpackage');
});
it('should have .name',function(){
should(myNpm).have.property('name','testpackage')
})
tap.test('should have .version', async () => {
expect(myNpm).property('version').toEqual('1.0.0');
});
it('should have .license',function(){
should(myNpm).have.property('license','MIT')
})
it('should have .git',function(){
should(myNpm.git.httpsUrl).equal('https://sometoken@github.com/someuser/somerepo.git')
})
tap.test('should have .name', async () => {
expect(myNpm).property('name').toEqual('testpackage');
});
})
tap.test('should have .license', async () => {
expect(myNpm).property('license').toEqual('MIT');
});
tap.test('should have .git', async () => {
expect(myNpm.git.httpsUrl).toEqual('https://sometoken@github.com/someuser/somerepo.git');
});
tap.test('should return a name', async () => {
expect(projectinfo.getNpmNameForDir(testBasePath)).toEqual('testpackage');
});
describe('.getNpmNameForDir()',function(){
it('should return a name',function(){
should(projectinfo.getNpmNameForDir(testBasePath)
).equal('testpackage')
})
})
})
tap.start();

View File

@ -1,32 +1,21 @@
import 'typings-global'
import plugins = require('./projectinfo.plugins')
import * as plugins from './projectinfo.plugins.js';
// direct access to classes
export * from './projectinfo.classes.git'
export * from './projectinfo.classes.npm'
export * from './projectinfo.classes.projectinfo'
export * from './projectinfo.classes.git.js';
export * from './projectinfo.classes.npm.js';
export * from './projectinfo.classes.projectinfo.js';
// npm
import { ProjectinfoNpm } from './projectinfo.classes.npm'
import { ProjectinfoNpm } from './projectinfo.classes.npm.js';
// 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(){
export let getNpmNameForDir = function (cwdArg) {
let localNpm = new ProjectinfoNpm(cwdArg);
if (localNpm.status === 'ok') {
return localNpm.name;
}
};
projectinfo.mojo = function(){
};
*/

View File

@ -1,29 +1,29 @@
import * as plugins from './projectinfo.plugins'
import * as plugins from './projectinfo.plugins.js';
export class ProjectinfoGit {
isGit: boolean
githost: string
gituser: string
gitrepo: string
cwd: string
constructor(cwdArg: string) {
this.cwd = cwdArg
this.getGitInfoFromPath()
}
isGit: boolean;
githost: string;
gituser: string;
gitrepo: string;
cwd: string;
constructor(cwdArg: string) {
this.cwd = cwdArg;
this.getGitInfoFromPath();
}
/**
* get git info from path
*/
getGitInfoFromPath() {
let localSmartpath = new plugins.smartpath.Smartpath(this.cwd)
this.gitrepo = localSmartpath.pathLevelsBackwards[0]
this.gituser = localSmartpath.pathLevelsBackwards[1]
}
/**
* get git info from path
*/
getGitInfoFromPath() {
let localSmartpath = new plugins.smartpath.Smartpath(this.cwd);
this.gitrepo = localSmartpath.pathLevelsBackwards[0];
this.gituser = localSmartpath.pathLevelsBackwards[1];
}
/**
* get git info from remote url
*/
getGitInfoFromRemote(remoteUrlArg: string) {
let gitRepoParsed = new plugins.smartstring.GitRepo(remoteUrlArg)
}
/**
* get git info from remote url
*/
getGitInfoFromRemote(remoteUrlArg: string) {
let gitRepoParsed = new plugins.smartstring.GitRepo(remoteUrlArg);
}
}

View File

@ -1,32 +1,32 @@
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: plugins.smartstring.GitRepo
import * as plugins from './projectinfo.plugins.js';
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)
};
}
};
export class ProjectinfoNpm {
isNpm: boolean = false;
packageJson: any;
name: string;
version: string;
status: string;
license: string;
git: plugins.smartstring.GitRepo;
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
);
}
}
}
}

View File

@ -1,20 +1,20 @@
import * as plugins from './projectinfo.plugins'
import { ProjectinfoNpm } from './projectinfo.classes.npm'
import { ProjectinfoGit } from './projectinfo.classes.git'
export type TProjectType = 'git' | 'npm'
import * as plugins from './projectinfo.plugins.js';
import { ProjectinfoNpm } from './projectinfo.classes.npm.js';
import { ProjectinfoGit } from './projectinfo.classes.git.js';
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
git: ProjectinfoGit
/**
* constructor of class ProjectInfo
*/
constructor(cwdArg: string) {
this.npm = new ProjectinfoNpm(cwdArg)
this.git = new ProjectinfoGit(cwdArg)
}
}
type: TProjectType;
npm: ProjectinfoNpm;
git: ProjectinfoGit;
/**
* constructor of class ProjectInfo
*/
constructor(cwdArg: string) {
this.npm = new ProjectinfoNpm(cwdArg);
this.git = new ProjectinfoGit(cwdArg);
}
}

View File

@ -1,6 +1,7 @@
import 'typings-global'
export import path = require('path')
export import q = require('q')
export import smartfile = require('smartfile')
export import smartstring = require('smartstring')
export import smartpath = require('smartpath')
import * as path from 'path';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartfile from '@pushrocks/smartfile';
import * as smartstring from '@pushrocks/smartstring';
import * as smartpath from '@pushrocks/smartpath';
export { path, smartpromise, smartfile, smartstring, smartpath };

9
tsconfig.json Normal file
View File

@ -0,0 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}