Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
24b3458888 | |||
cffa47ac3d | |||
9dadf3f78f | |||
b35a671fe9 | |||
0ca38c109e | |||
4e2321e1ee | |||
a640ab3d7b | |||
37d6d56287 | |||
443a026502 | |||
9644c5b7e3 | |||
25faa8c697 | |||
982387aaa3 |
104
.gitea/workflows/gitzone_ci_default.yaml
Normal file
104
.gitea/workflows/gitzone_ci_default.yaml
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
name: CI Pipeline
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
|
||||||
|
test:
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- 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: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm prepare
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci command npm run buildDocs
|
||||||
|
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: public
|
||||||
|
path: public
|
||||||
|
retention-days: 7
|
@ -13,31 +13,24 @@ stages:
|
|||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- npm install -g @shipzone/npmci
|
- pnpm install -g pnpm
|
||||||
|
- pnpm install -g @shipzone/npmci
|
||||||
|
- npmci npm prepare
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
mirror:
|
# ====================
|
||||||
stage: security
|
# security stage
|
||||||
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 config set registry https://registry.npmjs.org
|
||||||
- npmci command npm install --production --ignore-scripts
|
- npmci command pnpm audit --audit-level=high --prod
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
@ -45,11 +38,10 @@ 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
|
||||||
|
|
||||||
@ -60,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
|
||||||
@ -71,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
|
||||||
@ -100,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
|
||||||
@ -123,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
|
||||||
|
11323
package-lock.json
generated
11323
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartfile",
|
"name": "@pushrocks/smartfile",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "10.0.2",
|
"version": "10.0.8",
|
||||||
"description": "offers smart ways to work with files in nodejs",
|
"description": "offers smart ways to work with files in nodejs",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -28,28 +29,27 @@
|
|||||||
"@pushrocks/lik": "^6.0.0",
|
"@pushrocks/lik": "^6.0.0",
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartfile-interfaces": "^1.0.7",
|
"@pushrocks/smartfile-interfaces": "^1.0.7",
|
||||||
"@pushrocks/smarthash": "^2.1.10",
|
"@pushrocks/smarthash": "^3.0.1",
|
||||||
"@pushrocks/smartjson": "^4.0.6",
|
"@pushrocks/smartjson": "^5.0.5",
|
||||||
"@pushrocks/smartmime": "^1.0.5",
|
"@pushrocks/smartmime": "^1.0.5",
|
||||||
"@pushrocks/smartpath": "^5.0.5",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smartrequest": "^1.1.56",
|
"@pushrocks/smartrequest": "^2.0.11",
|
||||||
"@pushrocks/smartstream": "^2.0.3",
|
"@pushrocks/smartstream": "^2.0.3",
|
||||||
"@pushrocks/streamfunction": "^4.0.4",
|
"@pushrocks/streamfunction": "^4.0.4",
|
||||||
"@types/fs-extra": "^9.0.13",
|
"@types/fs-extra": "^11.0.0",
|
||||||
"@types/glob": "^7.2.0",
|
"@types/glob": "^8.0.0",
|
||||||
"@types/js-yaml": "^4.0.5",
|
"@types/js-yaml": "^4.0.5",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^11.1.0",
|
||||||
"glob": "^8.0.3",
|
"glob": "^8.0.3",
|
||||||
"js-yaml": "^4.1.0"
|
"js-yaml": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsrun": "^1.2.35",
|
"@gitzone/tsrun": "^1.2.39",
|
||||||
"@gitzone/tstest": "^1.0.71",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^17.0.41",
|
"@types/node": "^18.11.18"
|
||||||
"gulp-function": "^2.2.14"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
4396
pnpm-lock.yaml
generated
Normal file
4396
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
|
||||||
|
|
||||||
@ -45,7 +44,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)
|
|
||||||
|
16
test/test.ts
16
test/test.ts
@ -38,9 +38,7 @@ tap.test('.fs.listFolders() -> should get the file type from a string', async ()
|
|||||||
tap.test('.fs.listFilesSync() -> should get the file type from a string', async () => {
|
tap.test('.fs.listFilesSync() -> should get the file type from a string', async () => {
|
||||||
expect(smartfile.fs.listFilesSync('./test/testassets/')).toContain('mytest.json');
|
expect(smartfile.fs.listFilesSync('./test/testassets/')).toContain('mytest.json');
|
||||||
expect(smartfile.fs.listFilesSync('./test/testassets/')).not.toContain('notExistentFile');
|
expect(smartfile.fs.listFilesSync('./test/testassets/')).not.toContain('notExistentFile');
|
||||||
expect(smartfile.fs.listFilesSync('./test/testassets/', /mytest\.json/)).toContain(
|
expect(smartfile.fs.listFilesSync('./test/testassets/', /mytest\.json/)).toContain('mytest.json');
|
||||||
'mytest.json'
|
|
||||||
);
|
|
||||||
expect(smartfile.fs.listFilesSync('./test/testassets/', /mytests.json/)).not.toContain(
|
expect(smartfile.fs.listFilesSync('./test/testassets/', /mytests.json/)).not.toContain(
|
||||||
'mytest.json'
|
'mytest.json'
|
||||||
);
|
);
|
||||||
@ -133,9 +131,7 @@ tap.test('.fs.toObjectSync() -> should read an .json file to an object', async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('.fs.toStringSync() -> should read a file to a string', async () => {
|
tap.test('.fs.toStringSync() -> should read a file to a string', async () => {
|
||||||
expect(smartfile.fs.toStringSync('./test/testassets/mytest.txt')).toEqual(
|
expect(smartfile.fs.toStringSync('./test/testassets/mytest.txt')).toEqual('Some TestString &&%$');
|
||||||
'Some TestString &&%$'
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
@ -213,6 +209,14 @@ tap.test('should create, store and retrieve valid smartfiles', async () => {
|
|||||||
expect(retrievedString).toEqual(fileString);
|
expect(retrievedString).toEqual(fileString);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should get a hash', async () => {
|
||||||
|
const fileString = 'hi there';
|
||||||
|
const filePath = './test/testassets/utf8.txt';
|
||||||
|
const smartfileInstance = await smartfile.Smartfile.fromString(filePath, fileString, 'utf8');
|
||||||
|
const hash = await smartfileInstance.getHash();
|
||||||
|
console.log(hash);
|
||||||
|
});
|
||||||
|
|
||||||
tap.test('should wait for file to be ready', async () => {
|
tap.test('should wait for file to be ready', async () => {
|
||||||
await smartfile.fs.waitForFileToBeReady('./test/testassets/mytest.json');
|
await smartfile.fs.waitForFileToBeReady('./test/testassets/mytest.json');
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartfile',
|
name: '@pushrocks/smartfile',
|
||||||
version: '10.0.2',
|
version: '10.0.8',
|
||||||
description: 'offers smart ways to work with files in nodejs'
|
description: 'offers smart ways to work with files in nodejs'
|
||||||
}
|
}
|
||||||
|
@ -237,9 +237,29 @@ export class Smartfile extends plugins.smartjson.Smartjson {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getHash(typeArg: 'path' | 'content' | 'all' = 'all') {
|
||||||
|
const pathHash = await plugins.smarthash.sha256FromString(this.path);
|
||||||
|
const contentHash = await plugins.smarthash.sha256FromBuffer(this.contentBuffer);
|
||||||
|
const combinedHash = await plugins.smarthash.sha256FromString(pathHash + contentHash);
|
||||||
|
switch (typeArg) {
|
||||||
|
case 'path':
|
||||||
|
return pathHash;
|
||||||
|
case 'content':
|
||||||
|
return contentHash;
|
||||||
|
case 'all':
|
||||||
|
default:
|
||||||
|
return combinedHash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// update things
|
// update things
|
||||||
public updateFileName(fileNameArg: string) {
|
public updateFileName(fileNameArg: string) {
|
||||||
const oldFileName = this.parsedPath.base;
|
const oldFileName = this.parsedPath.base;
|
||||||
this.path = this.path.replace(new RegExp(oldFileName + '$'), fileNameArg);
|
this.path = this.path.replace(new RegExp(oldFileName + '$'), fileNameArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async editContentAsString(editFuncArg: (fileStringArg: string) => Promise<string>) {
|
||||||
|
const newFileString = await editFuncArg(this.contentBuffer.toString());
|
||||||
|
this.contentBuffer = Buffer.from(newFileString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ export const fileTreeToHash = async (dirPathArg: string, miniMatchFilter: string
|
|||||||
const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter);
|
const fileTreeObject = await fileTreeToObject(dirPathArg, miniMatchFilter);
|
||||||
let combinedString = '';
|
let combinedString = '';
|
||||||
for (const smartfile of fileTreeObject) {
|
for (const smartfile of fileTreeObject) {
|
||||||
combinedString += smartfile.contentBuffer.toString();
|
combinedString += await smartfile.getHash();
|
||||||
}
|
}
|
||||||
const hash = await plugins.smarthash.sha256FromString(combinedString);
|
const hash = await plugins.smarthash.sha256FromString(combinedString);
|
||||||
return hash;
|
return hash;
|
||||||
|
@ -11,7 +11,4 @@ export const createWriteStream = (pathArg: string) => {
|
|||||||
return plugins.fs.createWriteStream(pathArg);
|
return plugins.fs.createWriteStream(pathArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const streamDirectory = async (dirPathArg: string) => {};
|
||||||
export const streamDirectory = async (dirPathArg: string) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -26,7 +26,7 @@ export {
|
|||||||
smartpath,
|
smartpath,
|
||||||
smartpromise,
|
smartpromise,
|
||||||
smartrequest,
|
smartrequest,
|
||||||
smartstream
|
smartstream,
|
||||||
};
|
};
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
|
Reference in New Issue
Block a user