10 Commits

Author SHA1 Message Date
bccfe8b589 1.0.6 2023-07-12 00:32:18 +02:00
9fab416670 fix(core): update 2023-07-12 00:32:17 +02:00
7563e5ad13 switch to new org scheme 2023-07-11 01:11:42 +02:00
5813f7663e switch to new org scheme 2023-07-10 10:16:37 +02:00
5a67af7453 1.0.5 2021-08-10 12:06:08 +02:00
c672e1a7e2 fix(core): update 2021-08-10 12:06:07 +02:00
b9c1570988 1.0.4 2021-08-10 11:49:40 +02:00
1907d253be fix(core): update 2021-08-10 11:49:39 +02:00
75394aaf8b 1.0.3 2020-03-04 15:47:16 +00:00
147a792c4c fix(core): update 2020-03-04 15:47:15 +00:00
16 changed files with 5051 additions and 1780 deletions

View 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

View 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 @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

4
.gitignore vendored
View File

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

View File

@ -19,22 +19,36 @@ mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- lossless - lossless
- docker - docker
- notpriv - notpriv
snyk: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk 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 stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags: tags:
- lossless
- docker - docker
- notpriv allow_failure: true
# ==================== # ====================
# test stage # test stage
@ -49,9 +63,7 @@ testStable:
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- priv
testBuild: testBuild:
stage: test stage: test
@ -62,9 +74,7 @@ testBuild:
- npmci command npm run build - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- notpriv
release: release:
stage: release stage: release
@ -84,6 +94,8 @@ release:
codequality: codequality:
stage: metadata stage: metadata
allow_failure: true allow_failure: true
only:
- tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g tslint typescript
- npmci npm prepare - npmci npm prepare

24
.vscode/launch.json vendored
View File

@ -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"
} }
] ]
} }

View File

@ -15,7 +15,7 @@
"properties": { "properties": {
"projectType": { "projectType": {
"type": "string", "type": "string",
"enum": ["website", "element", "service", "npm"] "enum": ["website", "element", "service", "npm", "wcc"]
} }
} }
} }

View File

@ -3,10 +3,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartmime", "gitrepo": "smartmime",
"shortDescription": "a module to detect mime types", "description": "a module to detect mime types",
"npmPackagename": "@pushrocks/smartmime", "npmPackagename": "@push.rocks/smartmime",
"license": "MIT", "license": "MIT",
"projectDomain": "push.rocks" "projectDomain": "push.rocks"
} }

1670
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,44 @@
{ {
"name": "@pushrocks/smartmime", "name": "@push.rocks/smartmime",
"version": "1.0.2", "version": "1.0.6",
"private": false, "private": false,
"description": "a module to detect mime types", "description": "a module to detect mime types",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)", "build": "(tsbuild --web)",
"format": "(gitzone format)" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tstest": "^1.0.15", "@gitzone/tsrun": "^1.2.42",
"@pushrocks/tapbundle": "^3.0.7", "@gitzone/tstest": "^1.0.74",
"@types/node": "^10.11.7", "@pushrocks/tapbundle": "^5.0.8",
"tslint": "^5.11.0", "@types/node": "^20.4.1",
"tslint-config-prettier": "^1.15.0" "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@types/mime-types": "^2.1.0", "@types/mime-types": "^2.1.1",
"mime-types": "^2.1.26" "mime-types": "^2.1.35"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ],
"browserslist": [
"last 1 chrome versions"
],
"type": "module"
} }

4753
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,26 @@
# @pushrocks/smartmime # @push.rocks/smartmime
a module to detect mime types a module to detect mime types
## Availabililty and Links ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmime) * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartmime)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmime) * [gitlab.com (source)](https://gitlab.com/push.rocks/smartmime)
* [github.com (source mirror)](https://github.com/pushrocks/smartmime) * [github.com (source mirror)](https://github.com/push.rocks/smartmime)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmime/) * [docs (typedoc)](https://push.rocks.gitlab.io/smartmime/)
## Status for master ## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smartmime/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartmime/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartmime/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartmime/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartmime.svg)](https://www.npmjs.com/package/@pushrocks/smartmime) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartmime/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartmime) GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartmime/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartmime/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartmime)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartmime)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartmime)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartmime)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartmime)](https://lossless.cloud)
## Usage ## Usage
@ -26,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)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,30 +1,45 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartmime from '../ts/index'; import * as smartmime from '../ts/index.js';
tap.test('should detect image', async () => { tap.test('should detect image', async () => {
const filePath = 'file.jpg'; const filePath = 'file.jpg';
const fileType = smartmime.detectMimeType(filePath); const fileType = smartmime.detectMimeType(filePath);
console.log(fileType); console.log(fileType);
expect(smartmime.isBinary(filePath)).to.be.true; expect(smartmime.isBinary(filePath)).toBeTrue();
}); });
tap.test('should detect text', async () => { tap.test('should detect text', async () => {
const filePath = 'file.svg'; const filePath = 'file.svg';
const fileType = smartmime.detectMimeType(filePath); const fileType = smartmime.detectMimeType(filePath);
console.log(fileType); console.log(fileType);
expect(smartmime.isBinary(filePath)).to.be.false; expect(smartmime.isBinary(filePath)).toBeFalse();
}); });
tap.test('should detect json', async () => { tap.test('should detect json', async () => {
const filePath = 'file.json'; const filePath = 'file.json';
const fileType = smartmime.detectMimeType(filePath); const fileType = smartmime.detectMimeType(filePath);
console.log(fileType); console.log(fileType);
expect(smartmime.isBinary(filePath)).to.be.false; expect(smartmime.isBinary(filePath)).toBeFalse();
}); });
tap.test('should detect html', async () => { tap.test('should detect html', async () => {
const filePath = 'file.html'; const filePath = 'file.html';
const fileType = smartmime.detectMimeType(filePath); const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('text/html');
console.log(fileType);
});
tap.test('should detect woff', async () => {
const filePath = 'file.woff';
const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('font/woff');
console.log(fileType);
});
tap.test('should detect woff2', async () => {
const filePath = 'file.woff2';
const fileType = smartmime.detectMimeType(filePath);
expect(fileType).toEqual('font/woff2');
console.log(fileType); console.log(fileType);
}); });

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartmime',
version: '1.0.6',
description: 'a module to detect mime types'
}

View File

@ -1,19 +1,8 @@
import * as plugins from './smartmime.plugins'; import * as plugins from './smartmime.plugins.js';
export const binaryFileTypes = [ export const binaryFileTypes = ['jpg', 'png', 'pdf'];
'jpg',
'png',
'pdf'
];
export const supportedFileTypes = [ export const supportedFileTypes = ['json', 'html', 'svg', 'jpg', 'ts', 'js'];
'json',
'html',
'svg',
'jpg',
'ts',
'js',
];
export type TMimeTypes = 'image/jpeg' | 'image/svg+xml' | 'application/json' | 'text/html'; export type TMimeTypes = 'image/jpeg' | 'image/svg+xml' | 'application/json' | 'text/html';
@ -30,4 +19,8 @@ export const isBinary = (pathArg: string) => {
isBinary = pathArg.endsWith(`.${binaryFileType}`); isBinary = pathArg.endsWith(`.${binaryFileType}`);
} }
return isBinary; return isBinary;
} };
export const getEncoding = (pathArg: string) => {
return isBinary(pathArg) ? 'binary' : 'utf8';
};

View File

@ -1,13 +1,9 @@
// node native scope // node native scope
import * as path from 'path'; import * as path from 'path';
export { export { path };
path
};
// thirdparty scope // thirdparty scope
import mimeTypes from 'mime-types'; import mimeTypes from 'mime-types';
export { export { mimeTypes };
mimeTypes
};

View File

@ -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"
}