Compare commits

..

No commits in common. "master" and "v1.0.21" have entirely different histories.

15 changed files with 1099 additions and 22030 deletions

4
.gitignore vendored
View File

@ -15,6 +15,8 @@ node_modules/
# builds
dist/
dist_*/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -1,19 +1,16 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
- security
- test
- release
- metadata
# ====================
# security stage
@ -21,75 +18,60 @@ before_script:
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
- npmci git mirror
tags:
- lossless
- docker
- notpriv
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
- npmci command snyk test
tags:
- docker
allow_failure: true
- docker
- notpriv
# ====================
# test stage
# ====================
testStable:
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- lossless
- docker
- notpriv
- docker
- notpriv
# ====================
# metadata stage
@ -97,38 +79,33 @@ release:
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command tslint -c tslint.json ./ts/**/*.ts
tags:
- lossless
- docker
- priv
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- lossless
- docker
- notpriv
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -136,5 +113,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

11
.vscode/launch.json vendored
View File

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

26
.vscode/settings.json vendored
View File

@ -1,26 +0,0 @@
{
"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"]
}
}
}
}
}
}
]
}

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# @pushrocks/smartopen
open things
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartopen)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartopen)
* [github.com (source mirror)](https://github.com/pushrocks/smartopen)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartopen/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartopen/badges/master/build.svg)](https://gitlab.com/pushrocks/smartopen/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartopen/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartopen/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartopen.svg)](https://www.npmjs.com/package/@pushrocks/smartopen)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartopen/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartopen)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
Use TypeScript for best in class instellisense.
```typescript
import * as smartopen from '@pushrocks/smartopen';
const run = async () => {
await smartopen.openUrl('https://lossless.com');
};
run();
```
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -7,27 +7,13 @@
"coverageTreshold": 60
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartopen",
"description": "A library for opening URLs or files in the default application",
"npmPackagename": "@push.rocks/smartopen",
"license": "MIT",
"keywords": [
"URL opening",
"file handling",
"cross-platform",
"typescript",
"node.js",
"web development",
"automation",
"external resources"
]
"shortDescription": "open things",
"npmPackagename": "@pushrocks/smartopen",
"license": "MIT"
}
},
"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"
}
}

18979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,46 @@
{
"name": "@push.rocks/smartopen",
"version": "2.0.0",
"description": "A library for opening URLs or files in the default application",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"name": "@pushrocks/smartopen",
"version": "1.0.21",
"description": "open things",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "tstest test/",
"build": "tsbuild"
},
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartopen.git"
"url": "git+ssh://git@gitlab.com/pushrocks/smartopen.git"
},
"keywords": [
"URL opening",
"file handling",
"cross-platform",
"typescript",
"node.js",
"web development",
"automation",
"external resources"
"open"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/smartopen/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartopen",
"homepage": "https://gitlab.com/pushrocks/smartopen#README",
"dependencies": {
"open": "^8.4.0"
"opn": "^6.0.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.56",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^5.0.2",
"@types/node": "^17.0.21"
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.9",
"@types/node": "^12.0.4",
"tslint": "^5.17.0",
"tslint-config-prettier": "^1.18.0"
},
"private": false,
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}
}

3750
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

View File

@ -1,90 +0,0 @@
# @push.rocks/smartopen
open things
## Install
To start using `@push.rocks/smartopen`, you'll first need to install it using npm. In your terminal, navigate to your project directory and run:
```bash
npm install @push.rocks/smartopen --save
```
This command will add `@push.rocks/smartopen` as a dependency to your project, allowing you to use it in your TypeScript applications.
## Usage
### Getting Started with SmartOpen
`@push.rocks/smartopen` provides an easy way to programmatically open URLs using Node.js. This can be particularly useful in desktop applications or server-side scripts where you want to trigger opening a web page in the default browser. Below, you'll find comprehensive examples to get you started.
Before diving into the examples, ensure you have TypeScript setup in your project. TypeScript provides strong types for JavaScript, which enhances development through type checking and better tooling support.
### Basic Usage
Here is the simplest way to open a URL:
```typescript
import { openUrl } from '@push.rocks/smartopen';
async function openWebPage() {
await openUrl('https://example.com');
}
openWebPage().then(() => {
console.log('Web page opened successfully');
}).catch((error) => {
console.error('Failed to open web page:', error);
});
```
This function imports the `openUrl` method from `@push.rocks/smartopen` and executes it with a URL string. It opens the provided URL in the default web browser.
### Advanced Usage: Handling in Continuous Integration Environments
`@push.rocks/smartopen` intelligently detects if it's running in a Continuous Integration (CI) environment and avoids opening the browser in such cases. This is practical for automated testing or deployment scripts where opening a browser window would be unnecessary or problematic.
Here's how you can utilize `@push.rocks/smartopen` in an environment-aware manner:
```typescript
import { openUrl } from '@push.rocks/smartopen';
async function openLinkConditionally(url: string) {
const result = await openUrl(url);
if(result === null) {
console.log('Environment detected as CI, skipping browser opening.');
} else {
console.log('Browser should open shortly:', url);
}
}
openLinkConditionally('https://example.com')
.catch((error) => console.error('An error occurred:', error));
```
In this example, the `openUrl` function returns `null` if it detects that it's being run in a CI environment, allowing the calling code to handle this scenario appropriately.
### Conclusion
`@push.rocks/smartopen` provides a straightforward and effective solution for opening URLs from Node.js scripts, with smart handling for CI environments. Whether you're building a desktop application, developing a server-side application that interacts with web services, or creating automation scripts that open web pages, `@push.rocks/smartopen` offers a reliable method to achieve your goals.
Remember, the examples above demonstrate the basic and advanced usage of `@push.rocks/smartopen`. Depending on your specific needs, you might need to adjust the logic or combine it with other modules to create more complex and powerful applications.
## 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.
**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 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.
### Company Information
Task Venture Capital GmbH
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.
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

@ -1,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle';
import { expect, tap } from 'tapbundle';
import * as smartopen from '../ts/index.js';
import * as smartopen from '../ts/index';
tap.test('should open a webpage', async () => {
await smartopen.openUrl('https://lossless.com');

View File

@ -1,9 +1,10 @@
import open from 'open';
import open from 'opn';
import { ChildProcess } from 'child_process';
export let openUrl = async (urlArg: string) => {
export let openUrl = async urlArg => {
if (!(process.env.CI === 'true')) {
const childProcess = await open(urlArg, {
wait: false,
wait: false
});
return childProcess;
} else {

View File

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

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}