fix(core): update
This commit is contained in:
parent
871f152f2d
commit
1ddb442661
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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 @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
@ -125,7 +125,7 @@ pages:
|
|||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @git.zone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
|
27270
package-lock.json
generated
27270
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -9,22 +9,23 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@git.zone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@git.zone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@git.zone/tsrun": "^1.2.46",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@git.zone/tstest": "^1.0.77",
|
||||||
"@types/node": "^16.11.11",
|
"@push.rocks/tapbundle": "^5.0.8",
|
||||||
"tslint": "^6.1.3",
|
"@types/node": "^20.12.7"
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^9.0.1",
|
"@push.rocks/smartfile": "^11.0.14",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@push.rocks/smartpath": "^5.0.14",
|
||||||
"@pushrocks/smartshell": "^2.0.30",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"@pushrocks/smartunique": "^3.0.3"
|
"@push.rocks/smartshell": "^3.0.3",
|
||||||
|
"@push.rocks/smartunique": "^3.0.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
@ -50,5 +51,14 @@
|
|||||||
"machine learning",
|
"machine learning",
|
||||||
"document analysis",
|
"document analysis",
|
||||||
"text recognition"
|
"text recognition"
|
||||||
]
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://code.foss.global/push.rocks/smartocr.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartocr/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/smartocr#readme",
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
6943
pnpm-lock.yaml
generated
6943
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
10
test/test.ts
10
test/test.ts
@ -1,16 +1,16 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/tapbundle';
|
||||||
import * as smartocr from '../ts/index';
|
import * as smartocr from '../ts/index.js';
|
||||||
|
|
||||||
let testOcrInstance: smartocr.SmartOcr;
|
let testOcrInstance: smartocr.SmartOcr;
|
||||||
|
|
||||||
tap.test('should create a valid instance of Smartocr', async () => {
|
tap.test('should create a valid instance of Smartocr', async () => {
|
||||||
testOcrInstance = await smartocr.SmartOcr.createAndInit();
|
testOcrInstance = await smartocr.SmartOcr.createAndInit();
|
||||||
expect(testOcrInstance).to.be.instanceOf(smartocr.SmartOcr);
|
expect(testOcrInstance).toBeInstanceOf(smartocr.SmartOcr);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should ocr a pdfBuffer', async () => {
|
tap.test('should ocr a pdfBuffer', async () => {
|
||||||
const smartfile = await import('@pushrocks/smartfile');
|
const smartfile = await import('@push.rocks/smartfile');
|
||||||
const pdfBuffer = (await smartfile.Smartfile.fromFilePath('./test/demo_without_textlayer.pdf'))
|
const pdfBuffer = (await smartfile.SmartFile.fromFilePath('./test/demo_without_textlayer.pdf'))
|
||||||
.contentBuffer;
|
.contentBuffer;
|
||||||
const resultBuffer = await testOcrInstance.processPdfBuffer(pdfBuffer);
|
const resultBuffer = await testOcrInstance.processPdfBuffer(pdfBuffer);
|
||||||
console.log(resultBuffer);
|
console.log(resultBuffer);
|
||||||
|
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: '@push.rocks/smartocr',
|
||||||
|
version: '1.0.9',
|
||||||
|
description: 'A module that performs optical character recognition (OCR) using ocrmypdf.'
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from './smartocr.classes.smartocr';
|
export * from './smartocr.classes.smartocr.js';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './smartocr.plugins';
|
import * as plugins from './smartocr.plugins.js';
|
||||||
import * as paths from './smartocr.paths';
|
import * as paths from './smartocr.paths.js';
|
||||||
|
|
||||||
export class SmartOcr {
|
export class SmartOcr {
|
||||||
// STATIC
|
// STATIC
|
||||||
@ -18,10 +18,10 @@ export class SmartOcr {
|
|||||||
const uniqueString = plugins.smartunique.uni('doc_');
|
const uniqueString = plugins.smartunique.uni('doc_');
|
||||||
const originalPath = plugins.path.join(paths.noGitDir, `${uniqueString}.pdf`);
|
const originalPath = plugins.path.join(paths.noGitDir, `${uniqueString}.pdf`);
|
||||||
const processedPath = plugins.path.join(paths.noGitDir, `${uniqueString}_processed.pdf`);
|
const processedPath = plugins.path.join(paths.noGitDir, `${uniqueString}_processed.pdf`);
|
||||||
const originalSmartfile = await plugins.smartfile.Smartfile.fromBuffer(originalPath, pdfBufferArg);
|
const originalSmartfile = await plugins.smartfile.SmartFile.fromBuffer(originalPath, pdfBufferArg);
|
||||||
await originalSmartfile.write();
|
await originalSmartfile.write();
|
||||||
await this.smartshellInstance.exec(`ocrmypdf --rotate-pages ${originalPath} ${processedPath}`);
|
await this.smartshellInstance.exec(`ocrmypdf --rotate-pages ${originalPath} ${processedPath}`);
|
||||||
const processedSmartfile = await plugins.smartfile.Smartfile.fromFilePath(processedPath);
|
const processedSmartfile = await plugins.smartfile.SmartFile.fromFilePath(processedPath);
|
||||||
await originalSmartfile.delete();
|
await originalSmartfile.delete();
|
||||||
await processedSmartfile.delete();
|
await processedSmartfile.delete();
|
||||||
return processedSmartfile.contentBuffer;
|
return processedSmartfile.contentBuffer;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartocr.plugins';
|
import * as plugins from './smartocr.plugins.js';
|
||||||
|
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
||||||
export const noGitDir = plugins.path.join(packageDir, './.nogit');
|
export const noGitDir = plugins.path.join(packageDir, './.nogit');
|
@ -6,14 +6,16 @@ export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
import * as smartunique from '@pushrocks/smartunique';
|
import * as smartunique from '@push.rocks/smartunique';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartfile,
|
smartfile,
|
||||||
smartshell,
|
smartshell,
|
||||||
smartunique,
|
smartunique,
|
||||||
|
smartpath,
|
||||||
smartpromise
|
smartpromise
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user