feat(projectinfo): migrate project info loading to async factories and update build configuration
This commit is contained in:
@@ -119,6 +119,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
npmci node install stable
|
npmci node install stable
|
||||||
npmci npm install
|
npmci npm install
|
||||||
pnpm install -g @gitzone/tsdoc
|
pnpm install -g @git.zone/tsdoc
|
||||||
npmci command tsdoc
|
npmci command tsdoc
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@git.zone/cli": {
|
||||||
"npmGlobalTools": [],
|
|
||||||
"npmAccessLevel": "public"
|
|
||||||
},
|
|
||||||
"gitzone": {
|
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "code.foss.global",
|
"githost": "code.foss.global",
|
||||||
@@ -20,9 +16,19 @@
|
|||||||
"package-info",
|
"package-info",
|
||||||
"repository"
|
"repository"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tsdoc": {
|
"@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"
|
"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": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
21
package.json
21
package.json
@@ -8,7 +8,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "(tsbuild tsfolders)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -30,17 +30,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://code.foss.global/push.rocks/projectinfo",
|
"homepage": "https://code.foss.global/push.rocks/projectinfo",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.66",
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
"@git.zone/tsrun": "^1.2.44",
|
"@git.zone/tsrun": "^2.0.2",
|
||||||
"@git.zone/tstest": "^1.0.77",
|
"@git.zone/tstest": "^3.6.0",
|
||||||
"@push.rocks/tapbundle": "^5.0.12",
|
"@types/node": "^25.5.0"
|
||||||
"@types/node": "^20.4.8"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartfile": "^10.0.28",
|
"@push.rocks/smartfs": "^1.5.0",
|
||||||
"@push.rocks/smartpath": "^5.0.11",
|
"@push.rocks/smartpath": "^6.0.0",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.2.3",
|
||||||
"@push.rocks/smartstring": "^4.0.2"
|
"@push.rocks/smartstring": "^4.1.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@@ -51,7 +50,7 @@
|
|||||||
"dist_ts_web/**/*",
|
"dist_ts_web/**/*",
|
||||||
"assets/**/*",
|
"assets/**/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
".smartconfig.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
|||||||
11238
pnpm-lock.yaml
generated
11238
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
175
readme.md
175
readme.md
@@ -1,103 +1,158 @@
|
|||||||
# @push.rocks/projectinfo
|
# @push.rocks/projectinfo
|
||||||
|
|
||||||
gather information about projects. supports npm, git etc.
|
A tool for gathering project information, supporting npm, git, and more.
|
||||||
|
|
||||||
## Install
|
## Issue Reporting and Security
|
||||||
|
|
||||||
To install `@push.rocks/projectinfo`, you need a Node.js environment with npm. It's recommended to have TypeScript and ts-node installed for the best development experience. Run the following command:
|
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
|
```bash
|
||||||
npm install @push.rocks/projectinfo --save
|
npm install @push.rocks/projectinfo
|
||||||
```
|
```
|
||||||
|
|
||||||
This will add it to your project's `package.json` file and download the package into the `node_modules` folder.
|
Or with pnpm:
|
||||||
|
|
||||||
## Usage
|
```bash
|
||||||
|
pnpm install @push.rocks/projectinfo
|
||||||
|
```
|
||||||
|
|
||||||
The `@push.rocks/projectinfo` module provides a powerful interface to gather detailed information about your projects, focusing on common project management tools like npm and git. Below are various examples and use cases demonstrating how to use this module effectively.
|
This module is ESM-only and requires Node.js 18+.
|
||||||
|
|
||||||
### Setup
|
## Usage 🚀
|
||||||
|
|
||||||
First, make sure to import `ProjectInfo` from the package in your TypeScript file. Here's how to get started:
|
`@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
|
```typescript
|
||||||
import { ProjectInfo } from '@push.rocks/projectinfo';
|
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"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Gathering NPM Information
|
### NPM Info Only
|
||||||
|
|
||||||
If you wish to extract npm-related information such as the project name and version from your `package.json`, you can instantiate `ProjectInfo` and access the `npm` property.
|
Use `ProjectinfoNpm` directly when you only need package.json data:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
const projectInfo = new ProjectInfo('./path/to/your/project');
|
import { ProjectinfoNpm } from '@push.rocks/projectinfo';
|
||||||
console.log(`Project Name: ${projectInfo.npm.name}`);
|
|
||||||
console.log(`Project Version: ${projectInfo.npm.version}`);
|
|
||||||
```
|
|
||||||
|
|
||||||
This example assumes that your current working directory (`cwd`) is set correctly relative to your project. Adjust `'./path/to/your/project'` as necessary.
|
const npm = await ProjectinfoNpm.create('/path/to/project');
|
||||||
|
|
||||||
### Accessing Git Information
|
if (npm.isNpm) {
|
||||||
|
console.log(npm.name); // package name
|
||||||
Similarly, to extract git-related information, you can access the `git` property. This allows you to get details about the git repository;
|
console.log(npm.version); // package version
|
||||||
|
console.log(npm.license); // license field
|
||||||
```typescript
|
console.log(npm.packageJson); // full parsed package.json object
|
||||||
console.log(`Git Repository: ${projectInfo.git.gitrepo}`);
|
|
||||||
// Outputs the git repository name
|
|
||||||
|
|
||||||
console.log(`Git User/Organization: ${projectInfo.git.gituser}`);
|
|
||||||
// Outputs the git user or organization name
|
|
||||||
```
|
|
||||||
|
|
||||||
It is important to note that these git properties are parsed from the local git configuration, so your project needs to be initialized with git and properly configured.
|
|
||||||
|
|
||||||
### Working with Asynchronous Operations
|
|
||||||
|
|
||||||
While the basic usage examples above are synchronous, `@push.rocks/projectinfo` might also offer functionality that requires async/await for operations that involve I/O processes, such as reading files or fetching data from remote APIs. Always refer to the specific method documentation to understand its nature (synchronous or asynchronous) and use it appropriately in your code.
|
|
||||||
|
|
||||||
### Integrating with Other Push.rocks Modules
|
|
||||||
|
|
||||||
The `@push.rocks/projectinfo` package is designed to work seamlessly with other packages from the Push.rocks suite. For instance, it utilizes `@push.rocks/smartfile` for efficient file handling, `@push.rocks/smartpath` for path manipulations, and `@push.rocks/smartpromise` for enhanced promise-based operations. This interconnectivity allows for a more integrated and efficient toolset when managing complex project setups.
|
|
||||||
|
|
||||||
### Advanced Usage and Customization
|
|
||||||
|
|
||||||
For more advanced use cases, such as customizing the way information is gathered or integrating `@push.rocks/projectinfo` into larger workflows, you are encouraged to explore the package's source code and accompanying documentation. The modular design and comprehensive TypeScript typings facilitate customization and extension to meet specific project requirements.
|
|
||||||
|
|
||||||
### Error Handling
|
|
||||||
|
|
||||||
When utilizing `@push.rocks/projectinfo` in your project automation or scripts, make sure to implement proper error handling. This helps in gracefully handling situations where project information might be missing, malformatted, or when underlying tools (npm, git) are not available in the environment.
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
try {
|
|
||||||
const projectInfo = new ProjectInfo('./path/to/your/project');
|
|
||||||
// Use projectInfo as needed
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to gather project info:', error);
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Summary
|
#### With Git Access Token
|
||||||
|
|
||||||
`@push.rocks/projectinfo` offers a versatile and powerful API for gathering and managing project information, making it an invaluable tool for developers looking to automate project setups, CI/CD pipelines, or simply organize and access project metadata more efficiently. Its integration with npm and git provides a solid foundation for extracting, analyzing, and utilizing essential project data across various aspects of software development and deployment workflows.
|
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:
|
||||||
|
|
||||||
By leveraging TypeScript for development, users are afforded the benefits of static typing, including better autocompletion, easier refactorings, and improved code quality. This document has outlined basic and advanced usage scenarios, aiming to equip developers with the knowledge to effectively incorporate `@push.rocks/projectinfo` into their projects.
|
```typescript
|
||||||
|
const npm = await ProjectinfoNpm.create('/path/to/project', {
|
||||||
|
gitAccessToken: 'ghp_your_token_here',
|
||||||
|
});
|
||||||
|
|
||||||
Note: The examples above are designed to be straightforward and easy to follow. Depending on the complexity and requirements of your specific project, you might need to adapt these examples. Always refer to the official documentation and TypeScript typings for the most accurate and up-to-date information.
|
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
|
## License and Legal Information
|
||||||
|
|
||||||
This 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.
|
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.
|
**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
|
### 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 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.
|
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
|
### Company Information
|
||||||
|
|
||||||
Task Venture Capital GmbH
|
Task Venture Capital GmbH
|
||||||
Registered at District court Bremen HRB 35230 HB, Germany
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
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.
|
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.
|
||||||
|
|||||||
15
test/test.ts
15
test/test.ts
@@ -1,11 +1,16 @@
|
|||||||
import { tap, expect } from '@push.rocks/tapbundle';
|
import { tap, expect } from '@git.zone/tstest/tapbundle';
|
||||||
import * as smartpath from '@push.rocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as projectinfo from '../ts/index.js';
|
import * as projectinfo from '../ts/index.js';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
let testBasePath = path.resolve(smartpath.get.dirnameFromImportMetaUrl(import.meta.url));
|
let testBasePath = path.resolve(smartpath.get.dirnameFromImportMetaUrl(import.meta.url));
|
||||||
|
|
||||||
let myNpm = new projectinfo.ProjectinfoNpm(testBasePath, { gitAccessToken: 'sometoken' });
|
let myNpm: projectinfo.ProjectinfoNpm;
|
||||||
|
|
||||||
|
tap.test('should create ProjectinfoNpm instance', async () => {
|
||||||
|
myNpm = await projectinfo.ProjectinfoNpm.create(testBasePath, { gitAccessToken: 'sometoken' });
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('should have .packageJson', async () => {
|
tap.test('should have .packageJson', async () => {
|
||||||
expect(myNpm.packageJson).property('version').toEqual('1.0.0');
|
expect(myNpm.packageJson).property('version').toEqual('1.0.0');
|
||||||
expect(myNpm.packageJson).property('name').toEqual('testpackage');
|
expect(myNpm.packageJson).property('name').toEqual('testpackage');
|
||||||
@@ -23,10 +28,10 @@ tap.test('should have .license', async () => {
|
|||||||
expect(myNpm).property('license').toEqual('MIT');
|
expect(myNpm).property('license').toEqual('MIT');
|
||||||
});
|
});
|
||||||
tap.test('should have .git', async () => {
|
tap.test('should have .git', async () => {
|
||||||
expect(myNpm.git.httpsUrl).toEqual('https://sometoken@github.com/someuser/somerepo.git');
|
expect(myNpm.git!.httpsUrl).toEqual('https://sometoken@github.com/someuser/somerepo.git');
|
||||||
});
|
});
|
||||||
tap.test('should return a name', async () => {
|
tap.test('should return a name', async () => {
|
||||||
expect(projectinfo.getNpmNameForDir(testBasePath)).toEqual('testpackage');
|
expect(await projectinfo.getNpmNameForDir(testBasePath)).toEqual('testpackage');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
export default tap.start();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/projectinfo',
|
name: '@push.rocks/projectinfo',
|
||||||
version: '5.0.2',
|
version: '5.1.0',
|
||||||
description: 'gather information about projects. supports npm, git etc.'
|
description: 'A tool for gathering project information, supporting npm, git, and more.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import { ProjectinfoNpm } from './projectinfo.classes.npm.js';
|
|||||||
/**
|
/**
|
||||||
* gets the name from package.json in a specified directory
|
* gets the name from package.json in a specified directory
|
||||||
*/
|
*/
|
||||||
export let getNpmNameForDir = function (cwdArg) {
|
export let getNpmNameForDir = async function (cwdArg: string) {
|
||||||
let localNpm = new ProjectinfoNpm(cwdArg);
|
let localNpm = await ProjectinfoNpm.create(cwdArg);
|
||||||
if (localNpm.status === 'ok') {
|
if (localNpm.status === 'ok') {
|
||||||
return localNpm.name;
|
return localNpm.name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import * as plugins from './projectinfo.plugins.js';
|
import * as plugins from './projectinfo.plugins.js';
|
||||||
|
|
||||||
export class ProjectinfoGit {
|
export class ProjectinfoGit {
|
||||||
isGit: boolean;
|
isGit: boolean = false;
|
||||||
githost: string;
|
githost: string = '';
|
||||||
gituser: string;
|
gituser: string = '';
|
||||||
gitrepo: string;
|
gitrepo: string = '';
|
||||||
cwd: string;
|
cwd: string;
|
||||||
constructor(cwdArg: string) {
|
constructor(cwdArg: string) {
|
||||||
this.cwd = cwdArg;
|
this.cwd = cwdArg;
|
||||||
|
|||||||
@@ -2,31 +2,37 @@ import * as plugins from './projectinfo.plugins.js';
|
|||||||
|
|
||||||
export class ProjectinfoNpm {
|
export class ProjectinfoNpm {
|
||||||
isNpm: boolean = false;
|
isNpm: boolean = false;
|
||||||
packageJson: any;
|
packageJson: any = null;
|
||||||
name: string;
|
name: string = '';
|
||||||
version: string;
|
version: string = '';
|
||||||
status: string;
|
status: string = '';
|
||||||
license: string;
|
license: string = '';
|
||||||
git: plugins.smartstring.GitRepo;
|
git: plugins.smartstring.GitRepo | null = null;
|
||||||
|
|
||||||
constructor(cwdArg: string, optionsArg: { gitAccessToken?: string } = {}) {
|
private constructor() {}
|
||||||
let resolvedCwd = plugins.path.resolve(cwdArg);
|
|
||||||
if (plugins.smartfile.fs.fileExists(plugins.path.join(resolvedCwd, 'package.json'))) {
|
static async create(cwdArg: string, optionsArg: { gitAccessToken?: string } = {}): Promise<ProjectinfoNpm> {
|
||||||
this.isNpm = true;
|
const instance = new ProjectinfoNpm();
|
||||||
this.packageJson = plugins.smartfile.fs.toObjectSync(
|
const resolvedCwd = plugins.path.resolve(cwdArg);
|
||||||
plugins.path.join(resolvedCwd, 'package.json'),
|
const smartFsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||||
'json'
|
const packageJsonPath = plugins.path.join(resolvedCwd, 'package.json');
|
||||||
);
|
|
||||||
this.name = this.packageJson.name;
|
const fileExists = await smartFsInstance.file(packageJsonPath).exists();
|
||||||
this.version = this.packageJson.version;
|
if (fileExists) {
|
||||||
this.status = 'ok';
|
instance.isNpm = true;
|
||||||
this.license = this.packageJson.license;
|
const content = await smartFsInstance.file(packageJsonPath).encoding('utf8').read();
|
||||||
if (this.packageJson.repository) {
|
instance.packageJson = JSON.parse(content as string);
|
||||||
this.git = new plugins.smartstring.GitRepo(
|
instance.name = instance.packageJson.name;
|
||||||
this.packageJson.repository.url,
|
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
|
optionsArg.gitAccessToken
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,21 @@ export type TProjectType = 'git' | 'npm';
|
|||||||
* class projectinfo automatically examines a given directory and exposes relevant info about it
|
* class projectinfo automatically examines a given directory and exposes relevant info about it
|
||||||
*/
|
*/
|
||||||
export class ProjectInfo {
|
export class ProjectInfo {
|
||||||
type: TProjectType;
|
type: TProjectType = 'git';
|
||||||
npm: ProjectinfoNpm;
|
npm: ProjectinfoNpm;
|
||||||
git: ProjectinfoGit;
|
git: ProjectinfoGit;
|
||||||
/**
|
|
||||||
* constructor of class ProjectInfo
|
private constructor(npm: ProjectinfoNpm, git: ProjectinfoGit) {
|
||||||
*/
|
this.npm = npm;
|
||||||
constructor(cwdArg: string) {
|
this.git = git;
|
||||||
this.npm = new ProjectinfoNpm(cwdArg);
|
if (npm.isNpm) {
|
||||||
this.git = new ProjectinfoGit(cwdArg);
|
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,7 +1,7 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartfile from '@push.rocks/smartfile';
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
import * as smartstring from '@push.rocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
import * as smartpath from '@push.rocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
|
|
||||||
export { path, smartpromise, smartfile, smartstring, smartpath };
|
export { path, smartpromise, smartfs, smartstring, smartpath };
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"module": "NodeNext",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"verbatimModuleSyntax": true
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"dist_*/**/*.d.ts"
|
"dist_*/**/*.d.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user