39 Commits

Author SHA1 Message Date
0dbcfca79b v5.1.0 2026-03-26 08:35:13 +00:00
4a20f31b99 feat(projectinfo): migrate project info loading to async factories and update build configuration 2026-03-26 08:35:13 +00:00
9e79ea4e70 update description 2024-05-29 14:11:27 +02:00
ecc5dee2ee update tsconfig 2024-04-14 17:15:51 +02:00
5ac7470e24 update npmextra.json: githost 2024-04-01 21:33:28 +02:00
3f9e0f2907 update npmextra.json: githost 2024-04-01 19:57:31 +02:00
c3bc4630bd update npmextra.json: githost 2024-03-30 21:46:28 +01:00
3d346b0515 5.0.2 2023-08-08 18:06:23 +02:00
6d12041154 fix(core): update 2023-08-08 18:06:23 +02:00
db6b2aa8c1 switch to new org scheme 2023-07-11 00:06:23 +02:00
fd4bd1919e switch to new org scheme 2023-07-10 02:41:49 +02:00
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
6fbc179fcb 3.0.0 2016-11-26 23:18:46 +01:00
c17db19b9f added ProjectInfo main class 2016-11-26 23:18:33 +01:00
38 changed files with 8742 additions and 387 deletions

View File

@@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

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 +0,0 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- trigger
- pages
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
script:
- npmci command npmpage --host gitlab
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

34
.smartconfig.json Normal file
View File

@@ -0,0 +1,34 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "projectinfo",
"description": "A tool for gathering project information, supporting npm, git, and more.",
"npmPackagename": "@push.rocks/projectinfo",
"license": "MIT",
"keywords": [
"project-info",
"npm",
"git",
"typescript",
"package-info",
"repository"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": []
}
}

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
```

95
changelog.md Normal file
View File

@@ -0,0 +1,95 @@
# Changelog
## 2026-03-26 - 5.1.0 - feat(projectinfo)
migrate project info loading to async factories and update build configuration
- replace synchronous npm metadata loading with async factory methods in ProjectInfo and ProjectinfoNpm
- switch filesystem access from @push.rocks/smartfile to @push.rocks/smartfs and update helper/tests for async usage
- refresh build tooling and project metadata configuration, including .smartconfig.json and tsbuild script updates
## 2024-05-29 - 5.0.2 - maintenance
Repository metadata and configuration updates across 5.0.2.
- Updated project description
- Updated TypeScript configuration
- Updated npmextra.json githost settings
## 2023-08-08 - 5.0.1 - core
Small core maintenance release with repository organization updates.
- Fixed a core update
- Switched to the new organization scheme
## 2022-04-18 - 5.0.0 - core
Major release introducing an ESM migration.
- BREAKING CHANGE: switched the package to ESM
- Included a core update alongside the release
## 2020-06-01 - 4.0.3-4.0.5 - core
Grouped maintenance releases with repeated core update work.
- 4.0.3 and 4.0.4 delivered routine core fixes
- 4.0.5 introduced a breaking change by switching core packaging behavior toward ESM compatibility
## 2018-09-02 - 4.0.0-4.0.2 - package
Infrastructure and package metadata updates across the 4.0.x line.
- 4.0.0 updated CI configuration
- 4.0.1 fixed the private parameter in package.json
- 4.0.2 delivered another core update
## 2018-09-02 - 3.0.4-3.0.5 - scope
Dependency maintenance followed by a breaking scope adjustment.
- 3.0.4 updated dependencies
- 3.0.5 introduced a BREAKING CHANGE by changing scope
## 2017-09-22 - 3.0.1-3.0.3 - maintenance
Routine maintenance releases focused on dependencies, CI, and documentation.
- 3.0.1 updated dependencies and README
- 3.0.2 updated dependencies
- 3.0.3 updated CI
## 2016-11-26 - 3.0.0 - documentation
Documentation-only release.
- Updated README
## 2016-11-26 - 2.0.0 - core
Feature release introducing the main project information class.
- Added the ProjectInfo main class
## 2016-10-27 - 1.0.3-1.0.4 - maintenance
Project standards, tooling, and documentation improvements.
- 1.0.3 updated smartfile, CI base image, and added README
- 1.0.4 updated the project to meet newer standards
## 2016-06-08 - 1.0.1-1.0.2 - refactor
Dependency and structure updates across early 1.x releases.
- 1.0.1 updated dependencies and restructured code
- 1.0.2 updated dependencies, project structure, and typings configuration
## 2016-02-23 - 1.0.0 - core
Initial stable release with token handling improvements.
- Added token handling correctly
- Included a small lint fix
## 2016-02-21 - 0.0.3-0.0.5 - core
Early project setup and metadata expansion.
- 0.0.3 updated project structure
- 0.0.4 added .license support to the npm class
- 0.0.5 added repository information and git metadata
## 2016-02-20 - 0.0.0-0.0.2 - bootstrap
Initial bootstrap releases establishing the project foundation.
- Added Travis CI setup
- Added a second npm version
- Added the getName function

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,5 +0,0 @@
import 'typings-global';
export declare class ProjectinfoGit {
isGit: boolean;
constructor();
}

View File

@@ -1,8 +0,0 @@
"use strict";
require("typings-global");
class ProjectinfoGit {
constructor() {
}
}
exports.ProjectinfoGit = ProjectinfoGit;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8uY2xhc3Nlcy5naXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wcm9qZWN0aW5mby5jbGFzc2VzLmdpdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBRXZCO0lBRUk7SUFFQSxDQUFDO0NBQ0o7QUFMRCx3Q0FLQyJ9

View File

@@ -1,13 +0,0 @@
import 'typings-global';
export declare class ProjectinfoNpm {
isNpm: boolean;
packageJson: any;
name: string;
version: string;
status: string;
license: string;
git: any;
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvamVjdGluZm8uY2xhc3Nlcy5ucG0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wcm9qZWN0aW5mby5jbGFzc2VzLm5wbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLGlEQUFpRDtBQUNqRDtJQVNJLFlBQVksTUFBYyxFQUFFLGFBQTBDLEVBQUU7UUFSeEUsVUFBSyxHQUFZLEtBQUssQ0FBQTtRQVNsQixJQUFJLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtRQUM5QyxFQUFFLENBQUMsQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxVQUFVLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxFQUFFLGNBQWMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2xGLElBQUksQ0FBQyxLQUFLLEdBQUcsSUFBSSxDQUFBO1lBQ2pCLElBQUksQ0FBQyxXQUFXLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUNoRCxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FDYixXQUFXLEVBQ1gsY0FBYyxDQUNqQixFQUNELE1BQU0sQ0FDVCxDQUFBO1lBQ0QsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLElBQUksQ0FBQTtZQUNqQyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsT0FBTyxDQUFBO1lBQ3ZDLElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxDQUFBO1lBQ2xCLElBQUksQ0FBQyxPQUFPLEdBQUcsSUFBSSxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUE7WUFDdkMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO2dCQUM5QixJQUFJLENBQUMsR0FBRyxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsR0FBRyxFQUFFLFVBQVUsQ0FBQyxjQUFjLENBQUMsQ0FBQTtZQUMxRyxDQUFDO1lBQUEsQ0FBQztRQUNOLENBQUM7SUFDTCxDQUFDO0lBQUEsQ0FBQztDQUNMO0FBN0JELHdDQTZCQyJ9

View File

@@ -1,13 +0,0 @@
import { ProjectinfoNpm } from './projectinfo.classes.npm';
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;
/**
* this constructor
*/
constructor(cwdArg: string);
}

View File

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

View File

@@ -1,5 +0,0 @@
import 'typings-global';
export declare let path: any;
export declare let Q: any;
export import smartfile = require('smartfile');
export import smartstring = require('smartstring');

View File

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

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 Push.Rocks
Copyright (c) 2016 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,11 +0,0 @@
{
"npmts": {
"mode": "default",
"coverageTreshold": 80
},
"npmci": {
"globalNpmTools": [
"npmts"
]
}
}

View File

@@ -1,38 +1,59 @@
{
"name": "projectinfo",
"version": "2.0.0",
"description": "gather information about projects. supports npm, git etc.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/projectinfo",
"version": "5.1.0",
"private": false,
"description": "A tool for gathering project information, supporting npm, git, and more.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild tsfolders)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+https://gitlab.com/pushrocks/projectinfo.git"
"url": "https://code.foss.global/push.rocks/projectinfo.git"
},
"keywords": [
"project",
"project-info",
"npm",
"git",
"info",
"package"
"typescript",
"package-info",
"repository"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/projectinfo/issues"
},
"homepage": "https://gitlab.com/pushrocks/projectinfo#readme",
"homepage": "https://code.foss.global/push.rocks/projectinfo",
"devDependencies": {
"npmts-g": "^5.2.10",
"should": "^11.1.1",
"typings-test": "^1.0.3"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^2.0.2",
"@git.zone/tstest": "^3.6.0",
"@types/node": "^25.5.0"
},
"dependencies": {
"q": "^1.4.1",
"smartfile": "4.1.0",
"smartstring": "2.0.22",
"typings-global": "^1.0.14"
}
"@push.rocks/smartfs": "^1.5.0",
"@push.rocks/smartpath": "^6.0.0",
"@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartstring": "^4.1.0"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

8014
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@@ -0,0 +1 @@

158
readme.md Normal file
View File

@@ -0,0 +1,158 @@
# @push.rocks/projectinfo
A tool for gathering project information, supporting npm, git, and more.
## Issue Reporting and Security
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
## Install 📦
Install via npm:
```bash
npm install @push.rocks/projectinfo
```
Or with pnpm:
```bash
pnpm install @push.rocks/projectinfo
```
This module is ESM-only and requires Node.js 18+.
## Usage 🚀
`@push.rocks/projectinfo` provides an async API for extracting npm and git metadata from any project directory. It uses `@push.rocks/smartfs` under the hood for filesystem operations.
All classes use async factory methods — no synchronous constructors.
### Quick Start
```typescript
import { ProjectInfo, ProjectinfoNpm, getNpmNameForDir } from '@push.rocks/projectinfo';
```
### Get Full Project Info
The `ProjectInfo` class is the main entry point. It gathers both npm and git info from a given directory:
```typescript
import { ProjectInfo } from '@push.rocks/projectinfo';
const info = await ProjectInfo.create('./my-project');
// npm info
console.log(info.npm.name); // e.g. "@push.rocks/projectinfo"
console.log(info.npm.version); // e.g. "5.0.2"
console.log(info.npm.license); // e.g. "MIT"
console.log(info.npm.isNpm); // true if package.json exists
// git info (parsed from directory path)
console.log(info.git.gitrepo); // e.g. "projectinfo"
console.log(info.git.gituser); // e.g. "push.rocks"
// project type
console.log(info.type); // "npm" if package.json found, otherwise "git"
```
### NPM Info Only
Use `ProjectinfoNpm` directly when you only need package.json data:
```typescript
import { ProjectinfoNpm } from '@push.rocks/projectinfo';
const npm = await ProjectinfoNpm.create('/path/to/project');
if (npm.isNpm) {
console.log(npm.name); // package name
console.log(npm.version); // package version
console.log(npm.license); // license field
console.log(npm.packageJson); // full parsed package.json object
}
```
#### With Git Access Token
If your `package.json` has a `repository` field, `ProjectinfoNpm` will parse it into a `GitRepo` object. You can provide an access token for authenticated URLs:
```typescript
const npm = await ProjectinfoNpm.create('/path/to/project', {
gitAccessToken: 'ghp_your_token_here',
});
if (npm.git) {
console.log(npm.git.httpsUrl); // e.g. "https://ghp_your_token_here@github.com/user/repo.git"
}
```
### Git Info Only
Use `ProjectinfoGit` for path-based git metadata extraction:
```typescript
import { ProjectinfoGit } from '@push.rocks/projectinfo';
// Parses the directory path to extract git user and repo
const git = new ProjectinfoGit('/home/user/repos/myorg/myrepo');
console.log(git.gituser); // "myorg"
console.log(git.gitrepo); // "myrepo"
```
You can also parse a remote URL:
```typescript
git.getGitInfoFromRemote('git+https://github.com/someuser/somerepo.git');
```
### Quick Helper: Get Package Name
A convenience function to quickly get the npm package name from a directory:
```typescript
import { getNpmNameForDir } from '@push.rocks/projectinfo';
const name = await getNpmNameForDir('./my-project');
console.log(name); // e.g. "@push.rocks/projectinfo"
```
Returns `undefined` if no valid `package.json` is found.
### API Reference
| Class / Function | Description |
|---|---|
| `ProjectInfo.create(cwd)` | Async factory — gathers both npm + git info |
| `ProjectinfoNpm.create(cwd, opts?)` | Async factory — parses `package.json` |
| `ProjectinfoGit(cwd)` | Sync constructor — extracts git info from path |
| `getNpmNameForDir(cwd)` | Async helper — returns the npm package name |
### Types
```typescript
type TProjectType = 'git' | 'npm';
```
## License and Legal Information
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./license) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQiw2Q0FBNkM7QUFDN0MsSUFBSSxNQUFNLEdBQUcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxDQUFBO0FBQzlCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQTtBQUMxQixJQUFJLFlBQVksR0FBRyxJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFBO0FBRTFDLFFBQVEsQ0FBQyxhQUFhLEVBQUM7SUFDbkIsUUFBUSxDQUFDLGVBQWUsRUFBQztRQUNyQixJQUFJLEtBQUssR0FBRyxJQUFJLFdBQVcsQ0FBQyxjQUFjLENBQUMsWUFBWSxFQUFDLEVBQUMsY0FBYyxFQUFFLFdBQVcsRUFBQyxDQUFDLENBQUE7UUFDdEYsRUFBRSxDQUFDLDBCQUEwQixFQUFDO1lBQzFCLE1BQU0sQ0FBQyxLQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUMsT0FBTyxDQUFDLENBQUE7WUFDMUQsTUFBTSxDQUFDLEtBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBQyxhQUFhLENBQUMsQ0FBQTtRQUNqRSxDQUFDLENBQUMsQ0FBQTtRQUVGLEVBQUUsQ0FBQyxzQkFBc0IsRUFBQztZQUN0QixNQUFNLENBQUMsS0FBSyxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxTQUFTLEVBQUMsT0FBTyxDQUFDLENBQUE7UUFDbEQsQ0FBQyxDQUFDLENBQUE7UUFFRixFQUFFLENBQUMsbUJBQW1CLEVBQUM7WUFDbkIsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFDLElBQUksQ0FBQyxRQUFRLENBQUMsTUFBTSxFQUFDLGFBQWEsQ0FBQyxDQUFBO1FBQ3JELENBQUMsQ0FBQyxDQUFBO1FBRUYsRUFBRSxDQUFDLHNCQUFzQixFQUFDO1lBQ3RCLE1BQU0sQ0FBQyxLQUFLLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQTtRQUNoRCxDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxrQkFBa0IsRUFBQztZQUNsQixNQUFNLENBQUMsS0FBSyxDQUFDLEdBQUcsQ0FBQyxRQUFRLENBQUMsQ0FBQyxLQUFLLENBQUMsb0RBQW9ELENBQUMsQ0FBQTtRQUMxRixDQUFDLENBQUMsQ0FBQTtJQUVOLENBQUMsQ0FBQyxDQUFBO0lBRUYsUUFBUSxDQUFDLHFCQUFxQixFQUFDO1FBQzNCLEVBQUUsQ0FBQyxzQkFBc0IsRUFBQztZQUN0QixNQUFNLENBQUMsV0FBVyxDQUFDLGdCQUFnQixDQUFDLFlBQVksQ0FBQyxDQUM1QyxDQUFDLEtBQUssQ0FBQyxhQUFhLENBQUMsQ0FBQTtRQUM5QixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==

View File

@@ -1 +0,0 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAE3C,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,eAAe,EAAC;QACrB,IAAI,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,YAAY,EAAC,EAAC,cAAc,EAAC,WAAW,EAAC,CAAC,CAAC;QACvE,EAAE,CAAC,0BAA0B,EAAC;YAC1B,KAAK,CAAC,WAAW;iBACb,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAC,OAAO,CAAC,CAAC;YAC5C,KAAK,CAAC,WAAW;iBACb,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAC,aAAa,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sBAAsB,EAAC;YACtB,KAAK;iBACA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAC,OAAO,CAAC,CAAA;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mBAAmB,EAAC;YACnB,KAAK;iBACA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAC,aAAa,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;QAEH,EAAE,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,37 @@
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 '@git.zone/tstest/tapbundle';
import * as smartpath from '@push.rocks/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: projectinfo.ProjectinfoNpm;
it('should have .name',function(){
should(myNpm).have.property('name','testpackage')
})
tap.test('should create ProjectinfoNpm instance', async () => {
myNpm = await projectinfo.ProjectinfoNpm.create(testBasePath, { gitAccessToken: 'sometoken' });
});
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 .packageJson', async () => {
expect(myNpm.packageJson).property('version').toEqual('1.0.0');
expect(myNpm.packageJson).property('name').toEqual('testpackage');
});
})
tap.test('should have .version', async () => {
expect(myNpm).property('version').toEqual('1.0.0');
});
describe('.getNpmNameForDir()',function(){
it('should return a name',function(){
should(projectinfo.getNpmNameForDir(testBasePath)
).equal('testpackage')
})
})
})
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(await projectinfo.getNpmNameForDir(testBasePath)).toEqual('testpackage');
});
export default tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/projectinfo',
version: '5.1.0',
description: 'A tool for gathering project information, supporting npm, git, and more.'
}

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 = async function (cwdArg: string) {
let localNpm = await ProjectinfoNpm.create(cwdArg);
if (localNpm.status === 'ok') {
return localNpm.name;
}
};
projectinfo.mojo = function(){
};
*/

View File

@@ -1,8 +1,29 @@
import 'typings-global'
import * as plugins from './projectinfo.plugins.js';
export class ProjectinfoGit {
isGit: boolean
constructor() {
}
}
isGit: boolean = false;
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 remote url
*/
getGitInfoFromRemote(remoteUrlArg: string) {
let gitRepoParsed = new plugins.smartstring.GitRepo(remoteUrlArg);
}
}

View File

@@ -1,32 +1,38 @@
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
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 = null;
name: string = '';
version: string = '';
status: string = '';
license: string = '';
git: plugins.smartstring.GitRepo | null = null;
private constructor() {}
static async create(cwdArg: string, optionsArg: { gitAccessToken?: string } = {}): Promise<ProjectinfoNpm> {
const instance = new ProjectinfoNpm();
const resolvedCwd = plugins.path.resolve(cwdArg);
const smartFsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
const packageJsonPath = plugins.path.join(resolvedCwd, 'package.json');
const fileExists = await smartFsInstance.file(packageJsonPath).exists();
if (fileExists) {
instance.isNpm = true;
const content = await smartFsInstance.file(packageJsonPath).encoding('utf8').read();
instance.packageJson = JSON.parse(content as string);
instance.name = instance.packageJson.name;
instance.version = instance.packageJson.version;
instance.status = 'ok';
instance.license = instance.packageJson.license;
if (instance.packageJson.repository) {
instance.git = new plugins.smartstring.GitRepo(
instance.packageJson.repository.url,
optionsArg.gitAccessToken
);
}
}
return instance;
}
}

View File

@@ -1,21 +1,27 @@
import * as plugins from './projectinfo.plugins'
import { ProjectinfoNpm } from './projectinfo.classes.npm'
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
/**
* this constructor
*/
constructor(cwdArg: string) {
this.npm = new ProjectinfoNpm(cwdArg)
type: TProjectType = 'git';
npm: ProjectinfoNpm;
git: ProjectinfoGit;
private constructor(npm: ProjectinfoNpm, git: ProjectinfoGit) {
this.npm = npm;
this.git = git;
if (npm.isNpm) {
this.type = 'npm';
}
}
}
static async create(cwdArg: string): Promise<ProjectInfo> {
const npm = await ProjectinfoNpm.create(cwdArg);
const git = new ProjectinfoGit(cwdArg);
return new ProjectInfo(npm, git);
}
}

View File

@@ -1,5 +1,7 @@
import 'typings-global'
export let path = require('path')
export let Q = require('q')
export import smartfile = require('smartfile')
export import smartstring = require('smartstring')
import * as path from 'path';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartfs from '@push.rocks/smartfs';
import * as smartstring from '@push.rocks/smartstring';
import * as smartpath from '@push.rocks/smartpath';
export { path, smartpromise, smartfs, smartstring, smartpath };

15
tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

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