Compare commits
No commits in common. "master" and "v1.0.1" have entirely different histories.
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,20 +1,4 @@
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
node_modules/
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
125
.gitlab-ci.yml
125
.gitlab-ci.yml
@ -1,80 +1,38 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
- .yarn/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
- npmci test legacy
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testBuild:
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- npmci test lts
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
@ -82,59 +40,32 @@ testBuild:
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci commadn yarn global add npmpage
|
||||
- npmci command npmpage --publish gitlab
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
- public
|
||||
|
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@ -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
26
.vscode/settings.json
vendored
@ -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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# smartopen
|
||||
open things
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartopen)
|
||||
[](https://GitLab.com/pushrocks/smartopen)
|
||||
[](https://github.com/pushrocks/smartopen)
|
||||
[](https://pushrocks.gitlab.io/smartopen/)
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/smartopen/commits/master)
|
||||
[](https://GitLab.com/pushrocks/smartopen/commits/master)
|
||||
[](https://www.npmjs.com/package/smartopen)
|
||||
[](https://david-dm.org/pushrocks/smartopen)
|
||||
[](https://www.bithound.io/github/pushrocks/smartopen/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartopen)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
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)
|
||||
|
||||
[](https://push.rocks)
|
1
dist/index.d.ts
vendored
Normal file
1
dist/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare let openUrl: (urlArg: any) => Promise<void>;
|
15
dist/index.js
vendored
Normal file
15
dist/index.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const open = require("open");
|
||||
exports.openUrl = (urlArg) => __awaiter(this, void 0, void 0, function* () {
|
||||
open(urlArg);
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsNkJBQTZCO0FBRWxCLFFBQUEsT0FBTyxHQUFHLENBQU8sTUFBTTtJQUNoQyxJQUFJLENBQUMsTUFBTSxDQUFDLENBQUE7QUFDZCxDQUFDLENBQUEsQ0FBQSJ9
|
@ -1,33 +0,0 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"npmts": {
|
||||
"coverageTreshold": 60
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
18832
package-lock.json
generated
18832
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
56
package.json
56
package.json
@ -1,57 +1,27 @@
|
||||
{
|
||||
"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": "smartopen",
|
||||
"version": "1.0.1",
|
||||
"description": "open things",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild"
|
||||
"test": "(npmts)"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.56",
|
||||
"@gitzone/tstest": "^1.0.69",
|
||||
"@pushrocks/tapbundle": "^5.0.2",
|
||||
"@types/node": "^17.0.21"
|
||||
},
|
||||
"private": false,
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
"@types/open": "^0.0.29",
|
||||
"open": "^0.0.5"
|
||||
}
|
||||
}
|
||||
|
3750
pnpm-lock.yaml
generated
3750
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
|
90
readme.md
90
readme.md
@ -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.
|
@ -1,9 +0,0 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as smartopen from '../ts/index.js';
|
||||
|
||||
tap.test('should open a webpage', async () => {
|
||||
await smartopen.openUrl('https://lossless.com');
|
||||
});
|
||||
|
||||
tap.start();
|
15
ts/index.ts
15
ts/index.ts
@ -1,12 +1,5 @@
|
||||
import open from 'open';
|
||||
import open = require('open')
|
||||
|
||||
export let openUrl = async (urlArg: string) => {
|
||||
if (!(process.env.CI === 'true')) {
|
||||
const childProcess = await open(urlArg, {
|
||||
wait: false,
|
||||
});
|
||||
return childProcess;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
export let openUrl = async (urlArg) => {
|
||||
open(urlArg)
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
11
yarn.lock
Normal file
11
yarn.lock
Normal file
@ -0,0 +1,11 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@types/open@^0.0.29":
|
||||
version "0.0.29"
|
||||
resolved "https://registry.yarnpkg.com/@types/open/-/open-0.0.29.tgz#3de910012674909db14d608d1fde44ffa7a9ecea"
|
||||
|
||||
open@^0.0.5:
|
||||
version "0.0.5"
|
||||
resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc"
|
Loading…
x
Reference in New Issue
Block a user