Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dbcfca79b | |||
| 4a20f31b99 | |||
| 9e79ea4e70 | |||
| ecc5dee2ee | |||
| 5ac7470e24 | |||
| 3f9e0f2907 | |||
| c3bc4630bd | |||
| 3d346b0515 | |||
| 6d12041154 | |||
| db6b2aa8c1 | |||
| fd4bd1919e | |||
| 8c4404ff68 | |||
| f2e91b8e1b | |||
| 31bcc5f8c2 | |||
| 216eabe035 | |||
| bc79a9ae42 | |||
| b82b6de5f5 | |||
| b27c069177 | |||
| b25be551f6 | |||
| 47da0afd4b | |||
| f9296f1f26 | |||
| d013fbad50 | |||
| d5f72a76d9 | |||
| d26a8b02db | |||
| 9b3db5daca | |||
| 75d94111a9 | |||
| 4f425dfc93 | |||
| 0f2af7219e | |||
| 9abe15f871 | |||
| 27aa9f7166 | |||
| 0a1063e6c8 | |||
| f606dd6e6d | |||
| 5c608dd675 | |||
| b4f8093230 | |||
| aa903ec93e | |||
| 187721a511 | |||
| c457cbff6a | |||
| 6fbc179fcb | |||
| c17db19b9f | |||
| 481ab58d02 | |||
| 9030619046 | |||
| fcd559090a | |||
| f946d5b1d8 | |||
| 4fee4ec822 | |||
| 94a431ef33 | |||
| 142cc52f95 | |||
| 040120d034 | |||
| 0618e46cd8 | |||
| c255f08ea6 | |||
| a7035a56fc |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
||||
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
|
||||
25
.gitignore
vendored
25
.gitignore
vendored
@@ -1,7 +1,20 @@
|
||||
.idea/
|
||||
coverage/
|
||||
node_modules
|
||||
.nogit/
|
||||
|
||||
ts/**/*.js
|
||||
ts/**/*.js.map
|
||||
ts/typings/
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
34
.smartconfig.json
Normal file
34
.smartconfig.json
Normal 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": []
|
||||
}
|
||||
}
|
||||
12
.travis.yml
12
.travis.yml
@@ -1,12 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 'v4.2.6'
|
||||
- 'stable'
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@lossless.digital
|
||||
api_key:
|
||||
secure: G2ZQYeDEokGCWQcXeT9SJ4aUF0uZ41B1kM9WD7hZKMGM5hzbGSTXjd/bLWf2HfujvN9FWQYVv0y5OpbRck4xTuEDBPmC5AqXCfrtNj77n151VLO0cF4+Ya1l8OQWvw13hX+cux8UfxRVHUAxUt7CoW3q6FBO/vt1Mvo9u9ucxKdB4QHXmPdq8TwuFusPJYC+l2LdWiaSCEz2LpnyrDf6OjLl2Bt+8rID3Ikbi+5yXWv/n7bfiXyIlpJX/i4Efh/mqsSWp+ziVWaSdKdpYMFPxqyOfqQ/kjbzLCwdR72cD3+UoJPdGQ46Vq3ncZRq3KighWkYRzN76EOTI/quzfcAoz5CekETPh419lPuqs2w8wEeE2oP0yCCSH1SG1ljH8ASrADWsoHzWyVa8c/ovzWMOc3hgLey6xgbYVar0sC94bjjqJh8Y5qOak4idOpI/SXf0UT1TkirZTGfdSgRzg/E1Zqj262sxLeIv0yHsbnzgwUduj6PjfLztgLVAGO13csxksUSiKxT8Mbbqozv1sdz/0SgoZTMYfZSO5kYdBCqguJkJdEj1Dr4tM/0ca+mugHibavQxPJiWqnfNqxdlmywpzPHPHe5G2wzba2W62l3yPHF4rJBJuUi35ddWWOkAN1g9D2NHlByWfqF+WYRuTv1DPlw7ZpmgEVPPUlBPhC5YO8=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/projectinfo
|
||||
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
26
.vscode/settings.json
vendored
Normal 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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
95
changelog.md
Normal file
95
changelog.md
Normal 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
|
||||
16
dist/index.js
vendored
16
dist/index.js
vendored
@@ -1,16 +0,0 @@
|
||||
var projectinfo = {};
|
||||
//classes
|
||||
var ProjectinfoNPM = require("./projectinfo.npm");
|
||||
projectinfo.npm = function (cwdArg, optionsArg) {
|
||||
return new ProjectinfoNPM(cwdArg, optionsArg);
|
||||
};
|
||||
//quick functions
|
||||
projectinfo.getName = function (cwdArg) {
|
||||
var localNpm = projectinfo.npm(cwdArg);
|
||||
if (localNpm.status === "ok") {
|
||||
return localNpm.name;
|
||||
}
|
||||
};
|
||||
module.exports = projectinfo;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLElBQUksV0FBVyxHQUFPLEVBQUUsQ0FBQztBQUV6QixTQUFTO0FBQ1QsSUFBTyxjQUFjLFdBQVcsbUJBQW1CLENBQUMsQ0FBQztBQUNyRCxXQUFXLENBQUMsR0FBRyxHQUFHLFVBQVMsTUFBTSxFQUFDLFVBQVU7SUFDeEMsTUFBTSxDQUFDLElBQUksY0FBYyxDQUFDLE1BQU0sRUFBQyxVQUFVLENBQUMsQ0FBQztBQUNqRCxDQUFDLENBQUM7QUFFRixpQkFBaUI7QUFDakIsV0FBVyxDQUFDLE9BQU8sR0FBRyxVQUFTLE1BQU07SUFDakMsSUFBSSxRQUFRLEdBQUcsV0FBVyxDQUFDLEdBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUN2QyxFQUFFLENBQUMsQ0FBQyxRQUFRLENBQUMsTUFBTSxLQUFLLElBQUksQ0FBQyxDQUFBLENBQUM7UUFDMUIsTUFBTSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUM7SUFDekIsQ0FBQztBQUNMLENBQUMsQ0FBQztBQVlGLGlCQUFTLFdBQVcsQ0FBQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vcHJvamVjdGluZm8ucGx1Z2luc1wiKTtcbnZhciBwcm9qZWN0aW5mbzphbnkgPSB7fTtcblxuLy9jbGFzc2VzXG5pbXBvcnQgUHJvamVjdGluZm9OUE0gPSByZXF1aXJlKFwiLi9wcm9qZWN0aW5mby5ucG1cIik7XG5wcm9qZWN0aW5mby5ucG0gPSBmdW5jdGlvbihjd2RBcmcsb3B0aW9uc0FyZyl7XG4gICAgcmV0dXJuIG5ldyBQcm9qZWN0aW5mb05QTShjd2RBcmcsb3B0aW9uc0FyZyk7XG59O1xuXG4vL3F1aWNrIGZ1bmN0aW9uc1xucHJvamVjdGluZm8uZ2V0TmFtZSA9IGZ1bmN0aW9uKGN3ZEFyZyl7XG4gICAgdmFyIGxvY2FsTnBtID0gcHJvamVjdGluZm8ubnBtKGN3ZEFyZyk7XG4gICAgaWYgKGxvY2FsTnBtLnN0YXR1cyA9PT0gXCJva1wiKXtcbiAgICAgICAgcmV0dXJuIGxvY2FsTnBtLm5hbWU7XG4gICAgfVxufTtcblxuLyogVE9ET1xucHJvamVjdGluZm8uZ2l0ID0gZnVuY3Rpb24oKXtcblxufTtcblxucHJvamVjdGluZm8ubW9qbyA9IGZ1bmN0aW9uKCl7XG5cbn07XG4qL1xuXG5leHBvcnQgPSBwcm9qZWN0aW5mbzsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
||||
20
dist/projectinfo.npm.js
vendored
20
dist/projectinfo.npm.js
vendored
@@ -1,20 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = require("./projectinfo.plugins");
|
||||
var ProjectinfoNPM = (function () {
|
||||
function ProjectinfoNPM(cwdArg, optionsArg) {
|
||||
if (optionsArg === void 0) { optionsArg = {}; }
|
||||
this.packageJson = plugins.smartfile.readFileToObject(plugins.path.join(plugins.path.resolve(cwdArg), "package.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 = plugins.smartstring.git(this.packageJson.repository.url, optionsArg.gitAccessToken);
|
||||
}
|
||||
;
|
||||
}
|
||||
return ProjectinfoNPM;
|
||||
})();
|
||||
module.exports = ProjectinfoNPM;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2plY3RpbmZvLm5wbS50cyJdLCJuYW1lcyI6WyJQcm9qZWN0aW5mb05QTSIsIlByb2plY3RpbmZvTlBNLmNvbnN0cnVjdG9yIl0sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcsdUJBQXVCLENBQUMsQ0FBQztBQUNsRDtJQVFJQSx3QkFBWUEsTUFBYUEsRUFBQ0EsVUFBd0NBO1FBQXhDQywwQkFBd0NBLEdBQXhDQSxlQUF3Q0E7UUFDOURBLElBQUlBLENBQUNBLFdBQVdBLEdBQUdBLE9BQU9BLENBQUNBLFNBQVNBLENBQUNBLGdCQUFnQkEsQ0FDakRBLE9BQU9BLENBQUNBLElBQUlBLENBQUNBLElBQUlBLENBQ2JBLE9BQU9BLENBQUNBLElBQUlBLENBQUNBLE9BQU9BLENBQUNBLE1BQU1BLENBQUNBLEVBQzVCQSxjQUFjQSxDQUNqQkEsQ0FDSkEsQ0FBQ0E7UUFDRkEsSUFBSUEsQ0FBQ0EsSUFBSUEsR0FBR0EsSUFBSUEsQ0FBQ0EsV0FBV0EsQ0FBQ0EsSUFBSUEsQ0FBQ0E7UUFDbENBLElBQUlBLENBQUNBLE9BQU9BLEdBQUdBLElBQUlBLENBQUNBLFdBQVdBLENBQUNBLE9BQU9BLENBQUNBO1FBQ3hDQSxJQUFJQSxDQUFDQSxNQUFNQSxHQUFHQSxJQUFJQSxDQUFDQTtRQUNuQkEsSUFBSUEsQ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AgICAgIHBsdWdpbnMucGF0aC5qb2luKFxuICAgICAgICAgICAgICAgIHBsdWdpbnMucGF0aC5yZXNvbHZlKGN3ZEFyZyksXG4gICAgICAgICAgICAgICAgXCJwYWNrYWdlLmpzb25cIlxuICAgICAgICAgICAgKVxuICAgICAgICApO1xuICAgICAgICB0aGlzLm5hbWUgPSB0aGlzLnBhY2thZ2VKc29uLm5hbWU7XG4gICAgICAgIHRoaXMudmVyc2lvbiA9IHRoaXMucGFja2FnZUpzb24udmVyc2lvbjtcbiAgICAgICAgdGhpcy5zdGF0dXMgPSBcIm9rXCI7XG4gICAgICAgIHRoaXMubGljZW5zZSA9IHRoaXMucGFja2FnZUpzb24ubGljZW5zZTtcbiAgICAgICAgaWYgKHRoaXMucGFja2FnZUpzb24ucmVwb3NpdG9yeSl7XG4gICAgICAgICAgICB0aGlzLmdpdCA9IHBsdWdpbnMuc21hcnRzdHJpbmcuZ2l0KHRoaXMucGFja2FnZUpzb24ucmVwb3NpdG9yeS51cmwsb3B0aW9uc0FyZy5naXRBY2Nlc3NUb2tlbik7XG4gICAgICAgIH07XG5cbiAgICB9XG59XG5cbmV4cG9ydCA9IFByb2plY3RpbmZvTlBNOyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
||||
10
dist/projectinfo.plugins.js
vendored
10
dist/projectinfo.plugins.js
vendored
@@ -1,10 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = {
|
||||
path: require("path"),
|
||||
Q: require("q"),
|
||||
smartfile: require("smartfile"),
|
||||
smartstring: require("smartstring")
|
||||
};
|
||||
module.exports = plugins;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2plY3RpbmZvLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsNENBQTRDO0FBQzVDLElBQUksT0FBTyxHQUFHO0lBQ1YsSUFBSSxFQUFFLE9BQU8sQ0FBQyxNQUFNLENBQUM7SUFDckIsQ0FBQyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUM7SUFDZixTQUFTLEVBQUUsT0FBTyxDQUFDLFdBQVcsQ0FBQztJQUMvQixXQUFXLEVBQUUsT0FBTyxDQUFDLGFBQWEsQ0FBQztDQUN0QyxDQUFDO0FBRUYsaUJBQVMsT0FBTyxDQUFDIiwiZmlsZSI6InByb2plY3RpbmZvLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG52YXIgcGx1Z2lucyA9IHtcbiAgICBwYXRoOiByZXF1aXJlKFwicGF0aFwiKSxcbiAgICBROiByZXF1aXJlKFwicVwiKSxcbiAgICBzbWFydGZpbGU6IHJlcXVpcmUoXCJzbWFydGZpbGVcIiksXG4gICAgc21hcnRzdHJpbmc6IHJlcXVpcmUoXCJzbWFydHN0cmluZ1wiKVxufTtcblxuZXhwb3J0ID0gcGx1Z2luczsiXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
||||
@@ -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
|
||||
58
package.json
58
package.json
@@ -1,35 +1,59 @@
|
||||
{
|
||||
"name": "projectinfo",
|
||||
"version": "1.0.1",
|
||||
"description": "gather information about projects. supports npm, git etc.",
|
||||
"main": "dist/index.js",
|
||||
"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://github.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://github.com/pushrocks/projectinfo/issues"
|
||||
"url": "https://gitlab.com/pushrocks/projectinfo/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/projectinfo#readme",
|
||||
"homepage": "https://code.foss.global/push.rocks/projectinfo",
|
||||
"devDependencies": {
|
||||
"npmts": "^3.1.2",
|
||||
"should": "^8.2.2"
|
||||
"@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": "0.0.11",
|
||||
"smartstring": "0.0.2"
|
||||
}
|
||||
"@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
8014
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
158
readme.md
Normal file
158
readme.md
Normal 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.
|
||||
@@ -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"
|
||||
|
||||
40
test/test.js
40
test/test.js
@@ -1,40 +0,0 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var projectinfo = require("../dist/index.js");
|
||||
var should = require("should");
|
||||
var path = require("path");
|
||||
var testBasePath = path.resolve(__dirname);
|
||||
describe("projectinfo", function () {
|
||||
describe(".npm() return", function () {
|
||||
var myNpm = projectinfo.npm(testBasePath, { gitAccessToken: "sometoken" });
|
||||
it("should have .packageJson", function () {
|
||||
myNpm.packageJson
|
||||
.should.have.property("version", "1.0.0");
|
||||
myNpm.packageJson
|
||||
.should.have.property("name", "testpackage");
|
||||
});
|
||||
it("should have .version", function () {
|
||||
myNpm
|
||||
.should.have.property("version", "1.0.0");
|
||||
});
|
||||
it("should have .name", function () {
|
||||
myNpm
|
||||
.should.have.property("name", "testpackage");
|
||||
});
|
||||
it("should have .license", function () {
|
||||
myNpm
|
||||
.should.have.property("license", "MIT");
|
||||
});
|
||||
it("should have .git", function () {
|
||||
myNpm.git.httpsUrl
|
||||
.should.equal("https://sometoken@github.com/someuser/somerepo.git");
|
||||
});
|
||||
});
|
||||
describe(".getName()", function () {
|
||||
it("should return a name", function () {
|
||||
projectinfo.getName(testBasePath)
|
||||
.should.equal("testpackage");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksV0FBVyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQUFDO0FBQzlDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMs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7XG4gICAgICAgICAgICBteU5wbS5wYWNrYWdlSnNvblxuICAgICAgICAgICAgICAgLnNob3VsZC5oYXZlLnByb3BlcnR5KFwidmVyc2lvblwiLFwiMS4wLjBcIik7XG4gICAgICAgICAgICBteU5wbS5wYWNrYWdlSnNvblxuICAgICAgICAgICAgICAgLnNob3VsZC5oYXZlLnByb3BlcnR5KFwibmFtZVwiLFwidGVzdHBhY2thZ2VcIik7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGl0KFwic2hvdWxkIGhhdmUgLnZlcnNpb25cIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgbXlOcG1cbiAgICAgICAgICAgICAgICAuc2hvdWxkLmhhdmUucHJvcGVydHkoXCJ2ZXJzaW9uXCIsXCIxLjAuMFwiKVxuICAgICAgICB9KTtcblxuICAgICAgICBpdChcInNob3VsZCBoYXZlIC5uYW1lXCIsZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIG15TnBtXG4gICAgICAgICAgICAgICAgLnNob3VsZC5oYXZlLnByb3BlcnR5KFwibmFtZVwiLFwidGVzdHBhY2thZ2VcIik7XG4gICAgICAgIH0pO1xuXG4gICAgICAgIGl0KFwic2hvdWxkIGhhdmUgLmxpY2Vuc2VcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgbXlOcG1cbiAgICAgICAgICAgICAgICAuc2hvdWxkLmhhdmUucHJvcGVydHkoXCJsaWNlbnNlXCIsXCJNSVRcIik7XG4gICAgICAgIH0pO1xuICAgICAgICBpdChcInNob3VsZCBoYXZlIC5naXRcIixmdW5jdGlvbigpe1xuICAgICAgICAgICAgbXlOcG0uZ2l0Lmh0dHBzVXJsXG4gICAgICAgICAgICAgICAgLnNob3VsZC5lcXVhbChcImh0dHBzOi8vc29tZXRva2VuQGdpdGh1Yi5jb20vc29tZXVzZXIvc29tZXJlcG8uZ2l0XCIpO1xuICAgICAgICB9KTtcblxuICAgIH0pO1xuXG4gICAgZGVzY3JpYmUoXCIuZ2V0TmFtZSgpXCI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,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"}
|
||||
69
test/test.ts
69
test/test.ts
@@ -1,44 +1,37 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var projectinfo = require("../dist/index.js");
|
||||
var should = require("should");
|
||||
var path = require("path");
|
||||
var 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(){
|
||||
var myNpm = projectinfo.npm(testBasePath,{gitAccessToken:"sometoken"});
|
||||
it("should have .packageJson",function(){
|
||||
myNpm.packageJson
|
||||
.should.have.property("version","1.0.0");
|
||||
myNpm.packageJson
|
||||
.should.have.property("name","testpackage");
|
||||
});
|
||||
import * as path from 'path';
|
||||
let testBasePath = path.resolve(smartpath.get.dirnameFromImportMetaUrl(import.meta.url));
|
||||
|
||||
it("should have .version",function(){
|
||||
myNpm
|
||||
.should.have.property("version","1.0.0")
|
||||
});
|
||||
let myNpm: projectinfo.ProjectinfoNpm;
|
||||
|
||||
it("should have .name",function(){
|
||||
myNpm
|
||||
.should.have.property("name","testpackage");
|
||||
});
|
||||
tap.test('should create ProjectinfoNpm instance', async () => {
|
||||
myNpm = await projectinfo.ProjectinfoNpm.create(testBasePath, { gitAccessToken: 'sometoken' });
|
||||
});
|
||||
|
||||
it("should have .license",function(){
|
||||
myNpm
|
||||
.should.have.property("license","MIT");
|
||||
});
|
||||
it("should have .git",function(){
|
||||
myNpm.git.httpsUrl
|
||||
.should.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(".getName()",function(){
|
||||
it("should return a name",function(){
|
||||
projectinfo.getName(testBasePath)
|
||||
.should.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
8
ts/00_commitinfo_data.ts
Normal 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.'
|
||||
}
|
||||
46
ts/index.ts
46
ts/index.ts
@@ -1,29 +1,21 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./projectinfo.plugins");
|
||||
var projectinfo:any = {};
|
||||
import * as plugins from './projectinfo.plugins.js';
|
||||
|
||||
//classes
|
||||
import ProjectinfoNPM = require("./projectinfo.npm");
|
||||
projectinfo.npm = function(cwdArg,optionsArg){
|
||||
return new ProjectinfoNPM(cwdArg,optionsArg);
|
||||
// direct access to classes
|
||||
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.js';
|
||||
|
||||
// quick functions
|
||||
|
||||
/**
|
||||
* gets the name from package.json in a specified directory
|
||||
*/
|
||||
export let getNpmNameForDir = async function (cwdArg: string) {
|
||||
let localNpm = await ProjectinfoNpm.create(cwdArg);
|
||||
if (localNpm.status === 'ok') {
|
||||
return localNpm.name;
|
||||
}
|
||||
};
|
||||
|
||||
//quick functions
|
||||
projectinfo.getName = function(cwdArg){
|
||||
var localNpm = projectinfo.npm(cwdArg);
|
||||
if (localNpm.status === "ok"){
|
||||
return localNpm.name;
|
||||
}
|
||||
};
|
||||
|
||||
/* TODO
|
||||
projectinfo.git = function(){
|
||||
|
||||
};
|
||||
|
||||
projectinfo.mojo = function(){
|
||||
|
||||
};
|
||||
*/
|
||||
|
||||
export = projectinfo;
|
||||
29
ts/projectinfo.classes.git.ts
Normal file
29
ts/projectinfo.classes.git.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as plugins from './projectinfo.plugins.js';
|
||||
|
||||
export class ProjectinfoGit {
|
||||
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);
|
||||
}
|
||||
}
|
||||
38
ts/projectinfo.classes.npm.ts
Normal file
38
ts/projectinfo.classes.npm.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as plugins from './projectinfo.plugins.js';
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
27
ts/projectinfo.classes.projectinfo.ts
Normal file
27
ts/projectinfo.classes.projectinfo.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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 = '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);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./projectinfo.plugins");
|
||||
class ProjectinfoNPM {
|
||||
packageJson;
|
||||
name:string;
|
||||
version:string;
|
||||
status:string;
|
||||
license:string;
|
||||
git;
|
||||
|
||||
constructor(cwdArg:string,optionsArg:{gitAccessToken?:string} = {}){
|
||||
this.packageJson = plugins.smartfile.readFileToObject(
|
||||
plugins.path.join(
|
||||
plugins.path.resolve(cwdArg),
|
||||
"package.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 = plugins.smartstring.git(this.packageJson.repository.url,optionsArg.gitAccessToken);
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
export = ProjectinfoNPM;
|
||||
@@ -1,9 +1,7 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = {
|
||||
path: require("path"),
|
||||
Q: require("q"),
|
||||
smartfile: require("smartfile"),
|
||||
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 = plugins;
|
||||
export { path, smartpromise, smartfs, smartstring, smartpath };
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
|
||||
}
|
||||
}
|
||||
15
tsconfig.json
Normal file
15
tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user