Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
eed1c75aba | |||
6de2f36964 | |||
76e777a3ac | |||
165cd3737e | |||
2f11d1ba0f | |||
33692ff417 | |||
f408337186 | |||
bd6d574226 | |||
d5c2d167ec | |||
2af6d5a974 | |||
fdba21d60d | |||
c17ebca309 |
@ -12,40 +12,36 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
auditProductionDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
auditDevDependencies:
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
- npmci command pnpm audit --audit-level=high --dev
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
@ -56,7 +52,6 @@ auditDevDependencies:
|
|||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -67,10 +62,9 @@ testStable:
|
|||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command npm run build
|
- npmci npm build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -96,10 +90,9 @@ codequality:
|
|||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
@ -119,11 +112,9 @@ trigger:
|
|||||||
pages:
|
pages:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command npm run buildDocs
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartenv",
|
"gitrepo": "smartenv",
|
||||||
"shortDescription": "store things about your environment and let them travel across modules",
|
"description": "store things about your environment and let them travel across modules",
|
||||||
"npmPackagename": "@pushrocks/smartenv",
|
"npmPackagename": "@pushrocks/smartenv",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
11232
package-lock.json
generated
11232
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,13 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartenv",
|
"name": "@pushrocks/smartenv",
|
||||||
"version": "4.0.16",
|
"version": "5.0.4",
|
||||||
"description": "store things about your environment and let them travel across modules",
|
"description": "store things about your environment and let them travel across modules",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web && tsbundle npm)",
|
"build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
|
||||||
"testbrowser": "(npm test) && (node testbrowser.js)"
|
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,18 +25,16 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
"homepage": "https://gitlab.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.7"
|
||||||
"@types/node": "^14.11.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.56",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^2.0.7",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.31",
|
||||||
"@gitzone/tstest": "^1.0.48",
|
"@gitzone/tstest": "^1.0.68",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^5.0.2",
|
||||||
"@types/npm": "^2.0.31",
|
"@types/node": "^18.11.18",
|
||||||
"tslint": "^6.1.3",
|
"@types/npm": "^7.19.0"
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
|
4382
pnpm-lock.yaml
generated
Normal file
4382
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,6 @@ Code Style | [](htt
|
|||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
10
test/test.ts
10
test/test.ts
@ -1,5 +1,5 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as smartenv from '../ts/index';
|
import * as smartenv from '../ts/index.js';
|
||||||
|
|
||||||
let testEnv: smartenv.Smartenv;
|
let testEnv: smartenv.Smartenv;
|
||||||
|
|
||||||
@ -17,20 +17,20 @@ tap.test('should get os', async () => {
|
|||||||
const resultWindows = await testEnv.isWindowsAsync();
|
const resultWindows = await testEnv.isWindowsAsync();
|
||||||
const osModule = await import('os');
|
const osModule = await import('os');
|
||||||
if (resultMac) {
|
if (resultMac) {
|
||||||
expect(osModule.platform()).to.equal('darwin');
|
expect(osModule.platform()).toEqual('darwin');
|
||||||
console.log('platform is Mac!');
|
console.log('platform is Mac!');
|
||||||
} else if (resultLinux) {
|
} else if (resultLinux) {
|
||||||
expect(osModule.platform()).to.equal('linux');
|
expect(osModule.platform()).toEqual('linux');
|
||||||
console.log('platform is Linux!');
|
console.log('platform is Linux!');
|
||||||
} else {
|
} else {
|
||||||
expect(osModule.platform()).to.equal('win32');
|
expect(osModule.platform()).toEqual('win32');
|
||||||
console.log('platform is Windows!');
|
console.log('platform is Windows!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should state wether we are in CI', async () => {
|
tap.test('should state wether we are in CI', async () => {
|
||||||
if (process.env.CI) {
|
if (process.env.CI) {
|
||||||
expect(testEnv.isCI).to.be.true;
|
expect(testEnv.isCI).toBeTrue();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@pushrocks/smartenv',
|
||||||
|
version: '5.0.4',
|
||||||
|
description: 'store things about your environment and let them travel across modules'
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from './smartenv.classes.smartenv';
|
export * from './smartenv.classes.smartenv.js';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './smartenv.plugins';
|
import * as plugins from './smartenv.plugins.js';
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
export interface IEnvObject {
|
export interface IEnvObject {
|
||||||
@ -20,26 +20,23 @@ export class Smartenv {
|
|||||||
const moduleResult = await this.getSafeNodeModule(optionsArg.nodeModuleName);
|
const moduleResult = await this.getSafeNodeModule(optionsArg.nodeModuleName);
|
||||||
return moduleResult;
|
return moduleResult;
|
||||||
} else if (this.isBrowser) {
|
} else if (this.isBrowser) {
|
||||||
const moduleResult = await this.getSafeWebModule(optionsArg.webUrlArg, optionsArg.getFunction);
|
const moduleResult = await this.getSafeWebModule(
|
||||||
|
optionsArg.webUrlArg,
|
||||||
|
optionsArg.getFunction
|
||||||
|
);
|
||||||
|
return moduleResult;
|
||||||
} else {
|
} else {
|
||||||
console.error('platform for loading not supported by smartenv');
|
console.error('platform for loading not supported by smartenv');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getSafeNodeModule<T = any>(moduleNameArg: string): T {
|
public async getSafeNodeModule<T = any>(moduleNameArg: string): Promise<T> {
|
||||||
if (!this.isNode) {
|
if (!this.isNode) {
|
||||||
console.error('You tried to load a node module in a wrong context');
|
console.error(`You tried to load a node module in a wrong context: ${moduleNameArg}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line: function-constructor
|
// tslint:disable-next-line: function-constructor
|
||||||
return new Function(
|
return new Function(`return import('${moduleNameArg}')`)() as Promise<T>;
|
||||||
'exports',
|
|
||||||
'require',
|
|
||||||
'module',
|
|
||||||
'__filename',
|
|
||||||
'__dirname',
|
|
||||||
`return require('${moduleNameArg}')`
|
|
||||||
)(exports, require, module, __filename, __dirname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadedScripts: string[] = [];
|
public loadedScripts: string[] = [];
|
||||||
@ -72,10 +69,10 @@ export class Smartenv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public get runtimeEnv() {
|
public get runtimeEnv() {
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof process !== 'undefined') {
|
||||||
return 'browser';
|
|
||||||
} else if (typeof process !== 'undefined') {
|
|
||||||
return 'node';
|
return 'node';
|
||||||
|
} else {
|
||||||
|
return 'browser';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +111,7 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isMacAsync(): Promise<boolean> {
|
public async isMacAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = this.getSafeNodeModule('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'darwin';
|
return os.platform() === 'darwin';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -123,7 +120,7 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isWindowsAsync(): Promise<boolean> {
|
public async isWindowsAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = this.getSafeNodeModule('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'win32';
|
return os.platform() === 'win32';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -132,7 +129,7 @@ export class Smartenv {
|
|||||||
|
|
||||||
public async isLinuxAsync(): Promise<boolean> {
|
public async isLinuxAsync(): Promise<boolean> {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
const os = this.getSafeNodeModule('os');
|
const os = await this.getSafeNodeModule('os');
|
||||||
return os.platform() === 'linux';
|
return os.platform() === 'linux';
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -145,10 +142,7 @@ export class Smartenv {
|
|||||||
public async printEnv() {
|
public async printEnv() {
|
||||||
if (this.isNode) {
|
if (this.isNode) {
|
||||||
console.log('running on NODE');
|
console.log('running on NODE');
|
||||||
const smartenvVersion = require('../package.json').version;
|
console.log('node version is ' + this.nodeVersion);
|
||||||
console.log(
|
|
||||||
'node version is ' + this.nodeVersion + ' and smartenv version is ' + smartenvVersion
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
console.log('running on BROWSER');
|
console.log('running on BROWSER');
|
||||||
console.log('browser is ' + this.userAgent);
|
console.log('browser is ' + this.userAgent);
|
||||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext"
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
Reference in New Issue
Block a user