Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
bdcfcee37a | |||
d41878721c | |||
3f69d55f5f | |||
ae015e433d | |||
f86145f68b | |||
2b908c3e4b | |||
dfb77842d3 | |||
f13a99447d | |||
aac5a11a7a | |||
36a1054b45 | |||
6aef7da9c4 | |||
1a1ceba76d | |||
c931a0459a | |||
a9eccfefc1 | |||
92a884354d | |||
008208dd0b | |||
94d60b8a73 | |||
c41316eb28 | |||
8071a0d529 | |||
a4c9679ccc | |||
b16cfe0aac |
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: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{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 @ship.zone/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 @ship.zone/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 @ship.zone/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 @ship.zone/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
|
140
.gitlab-ci.yml
140
.gitlab-ci.yml
@ -1,140 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
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:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm 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
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
66
changelog.md
Normal file
66
changelog.md
Normal file
@ -0,0 +1,66 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-11-06 - 2.2.5 - fix(ci)
|
||||
Corrected docker image URLs in Gitea workflows to match the correct domain format.
|
||||
|
||||
- Updated IMAGE environment variable in .gitea/workflows/default_nottags.yaml
|
||||
- Updated IMAGE environment variable in .gitea/workflows/default_tags.yaml
|
||||
|
||||
## 2024-11-06 - 2.2.4 - fix(core)
|
||||
Improve code style and update dependencies
|
||||
|
||||
- Updated @push.rocks/tapbundle to version ^5.4.3 in package.json.
|
||||
- Fixed markdown formatting in readme.md.
|
||||
- Improved code consistency in ts/00_commitinfo_data.ts, ts/plugins.ts, and test/test.ts.
|
||||
|
||||
## 2024-11-06 - 2.2.3 - fix(core)
|
||||
Fix endpoint address from 'localhost' to '127.0.0.1' for better compatibility in Smarts3.getS3Descriptor
|
||||
|
||||
- Corrected the endpoint address in Smarts3.getS3Descriptor to ensure proper functioning across different environments.
|
||||
|
||||
## 2024-11-06 - 2.2.2 - fix(core)
|
||||
Fixed function call for fastPut in the test suite to ensure proper file upload handling.
|
||||
|
||||
- Updated dependencies in package.json to newer versions.
|
||||
- Corrected the function call in test suite for file upload.
|
||||
|
||||
## 2024-10-26 - 2.2.1 - fix(core)
|
||||
Fix import and typings for improved compatibility
|
||||
|
||||
- Corrected the type signature for `getS3Descriptor` to return `IS3Descriptor`.
|
||||
- Fixed import structure and updated dependencies for consistent namespace usage across plugins.
|
||||
|
||||
## 2024-10-26 - 2.2.0 - feat(ci)
|
||||
Migrate CI/CD workflow from GitLab CI to Gitea CI
|
||||
|
||||
- Added new Gitea CI workflows for both non-tag and tag-based pushes
|
||||
- Removed existing GitLab CI configuration
|
||||
|
||||
## 2024-05-29 - 2.1.1 - Updates and minor changes
|
||||
Updates and changes based on minor configuration improvements and organizational shifts.
|
||||
|
||||
- Updated description file.
|
||||
- Updated tsconfig settings.
|
||||
- Updated npmextra.json with new githost configuration.
|
||||
- Shifted to new organizational scheme.
|
||||
|
||||
## 2022-07-30 - 2.1.0 - Core improvements and fixes
|
||||
Minor improvements and important core changes.
|
||||
|
||||
- Removed tslint from the core setup.
|
||||
|
||||
## 2022-07-30 - 2.0.2 - Bucket creation improvement
|
||||
Enhanced file structure management.
|
||||
|
||||
- Improved bucket creation to store locally within the .nogit directory.
|
||||
|
||||
## 2022-04-14 - 2.0.0 to 2.0.1 - Structural updates and fixes
|
||||
This release focused on core updates and structural changes.
|
||||
|
||||
- Reformatted the project structure.
|
||||
- Core updates with minor fixes.
|
||||
|
||||
## 2021-12-20 - 1.0.10 - ESM Transition
|
||||
Breaking changes and minor fixes, transitioning to ES Modules.
|
||||
|
||||
- BREAKING CHANGE: Transitioned core setup to ESM.
|
@ -2,17 +2,38 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smarts3",
|
||||
"description": "create an s3 endpoint that maps to a local directory",
|
||||
"npmPackagename": "@pushrocks/smarts3",
|
||||
"description": "A Node.js TypeScript package to create a local S3 endpoint for simulating AWS S3 operations using mapped local directories for development and testing purposes.",
|
||||
"npmPackagename": "@push.rocks/smarts3",
|
||||
"license": "MIT",
|
||||
"projectDomain": "push.rocks"
|
||||
"projectDomain": "push.rocks",
|
||||
"keywords": [
|
||||
"S3 Mock Server",
|
||||
"Local S3",
|
||||
"Node.js",
|
||||
"TypeScript",
|
||||
"Local Development",
|
||||
"Testing",
|
||||
"Cloud Storage",
|
||||
"File Storage",
|
||||
"AWS S3 Compatibility",
|
||||
"Development Tool",
|
||||
"S3 Endpoint",
|
||||
"S3 Simulation",
|
||||
"Bucket Management",
|
||||
"File Upload",
|
||||
"CI/CD Integration",
|
||||
"Developer Onboarding"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
17004
package-lock.json
generated
17004
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@pushrocks/smarts3",
|
||||
"version": "2.1.0",
|
||||
"name": "@push.rocks/smarts3",
|
||||
"version": "2.2.5",
|
||||
"private": false,
|
||||
"description": "create an s3 endpoint that maps to a local directory",
|
||||
"description": "A Node.js TypeScript package to create a local S3 endpoint for simulating AWS S3 operations using mapped local directories for development and testing purposes.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@ -10,16 +10,16 @@
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsbundle": "^2.0.6",
|
||||
"@gitzone/tstest": "^1.0.72",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.6.2",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.72",
|
||||
"@push.rocks/tapbundle": "^5.4.3",
|
||||
"@types/node": "^22.9.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
@ -37,10 +37,37 @@
|
||||
"readme.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"@pushrocks/smartbucket": "^2.0.2",
|
||||
"@pushrocks/smartfile": "^10.0.4",
|
||||
"@pushrocks/smartpath": "^5.0.5",
|
||||
"@push.rocks/smartbucket": "^3.0.23",
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartpath": "^5.0.5",
|
||||
"@tsclass/tsclass": "^4.1.2",
|
||||
"@types/s3rver": "^3.7.0",
|
||||
"s3rver": "^3.7.1"
|
||||
},
|
||||
"keywords": [
|
||||
"S3 Mock Server",
|
||||
"Local S3",
|
||||
"Node.js",
|
||||
"TypeScript",
|
||||
"Local Development",
|
||||
"Testing",
|
||||
"Cloud Storage",
|
||||
"File Storage",
|
||||
"AWS S3 Compatibility",
|
||||
"Development Tool",
|
||||
"S3 Endpoint",
|
||||
"S3 Simulation",
|
||||
"Bucket Management",
|
||||
"File Upload",
|
||||
"CI/CD Integration",
|
||||
"Developer Onboarding"
|
||||
],
|
||||
"homepage": "https://code.foss.global/push.rocks/smarts3#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://code.foss.global/push.rocks/smarts3.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://code.foss.global/push.rocks/smarts3/issues"
|
||||
}
|
||||
}
|
||||
|
8182
pnpm-lock.yaml
generated
Normal file
8182
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
236
readme.md
236
readme.md
@ -1,39 +1,219 @@
|
||||
# @pushrocks/smarts3
|
||||
create an s3 endpoint that maps to a local directory
|
||||
````markdown
|
||||
# @push.rocks/smarts3
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smarts3)
|
||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smarts3)
|
||||
* [github.com (source mirror)](https://github.com/pushrocks/smarts3)
|
||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smarts3/)
|
||||
A Node.js TypeScript package to create a local S3 endpoint for development and testing using mapped local directories, simulating AWS S3.
|
||||
|
||||
## Status for master
|
||||
## Install
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
To integrate `@push.rocks/smarts3` with your project, you need to install it via npm. Execute the following command within your project's root directory:
|
||||
|
||||
```sh
|
||||
npm install @push.rocks/smarts3 --save
|
||||
```
|
||||
````
|
||||
|
||||
This command will add `@push.rocks/smarts3` as a dependency in your project's `package.json` file and download the package into the `node_modules` directory.
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense
|
||||
### Overview
|
||||
|
||||
## Contribution
|
||||
The `@push.rocks/smarts3` module allows users to create a mock S3 endpoint that maps to a local directory using `s3rver`. This simulation of AWS S3 operations facilitates development and testing by enabling file uploads, bucket creation, and other interactions locally. This local setup is ideal for developers looking to test cloud file storage operations without requiring access to a real AWS S3 instance.
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
In this comprehensive guide, we will explore setting up a local S3 server, performing operations like creating buckets and uploading files, and how to effectively integrate this into your development workflow.
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
### Setting Up the Environment
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
To begin any operations, your environment must be configured correctly. Here’s a simple setup procedure:
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
```typescript
|
||||
import * as path from 'path';
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
async function setupEnvironment() {
|
||||
const packageDir = path.resolve();
|
||||
const nogitDir = path.join(packageDir, './.nogit');
|
||||
const bucketsDir = path.join(nogitDir, 'bucketsDir');
|
||||
|
||||
try {
|
||||
await fs.mkdir(bucketsDir, { recursive: true });
|
||||
} catch (error) {
|
||||
console.error('Failed to create buckets directory!', error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
console.log('Environment setup complete.');
|
||||
}
|
||||
|
||||
setupEnvironment().catch(console.error);
|
||||
```
|
||||
|
||||
This script sets up a directory structure required for the `smarts3` server, ensuring that the directories needed for bucket storage exist before starting the server.
|
||||
|
||||
### Starting the S3 Server
|
||||
|
||||
Once your environment is set up, start an instance of the `smarts3` server. This acts as your local mock S3 endpoint:
|
||||
|
||||
```typescript
|
||||
import { Smarts3 } from '@push.rocks/smarts3';
|
||||
|
||||
async function startServer() {
|
||||
const smarts3Instance = await Smarts3.createAndStart({
|
||||
port: 3000,
|
||||
cleanSlate: true,
|
||||
});
|
||||
|
||||
console.log('S3 server is up and running at http://localhost:3000');
|
||||
return smarts3Instance;
|
||||
}
|
||||
|
||||
startServer().catch(console.error);
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- **Port**: Specify the port for the local S3 server. Defaults to `3000`.
|
||||
- **CleanSlate**: If `true`, clears the storage directory each time the server starts, providing a fresh test state.
|
||||
|
||||
### Creating and Managing Buckets
|
||||
|
||||
With your server running, create buckets for storing files. A bucket in S3 acts similarly to a root directory.
|
||||
|
||||
```typescript
|
||||
async function createBucket(smarts3Instance: Smarts3, bucketName: string) {
|
||||
const bucket = await smarts3Instance.createBucket(bucketName);
|
||||
console.log(`Bucket created: ${bucket.name}`);
|
||||
}
|
||||
|
||||
startServer()
|
||||
.then((smarts3Instance) => createBucket(smarts3Instance, 'my-awesome-bucket'))
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
### Uploading and Managing Files
|
||||
|
||||
Uploading files to a bucket uses the `SmartBucket` module, part of the `@push.rocks/smartbucket` ecosystem:
|
||||
|
||||
```typescript
|
||||
import { SmartBucket } from '@push.rocks/smartbucket';
|
||||
|
||||
async function uploadFile(
|
||||
smarts3Instance: Smarts3,
|
||||
bucketName: string,
|
||||
filePath: string,
|
||||
fileContent: string,
|
||||
) {
|
||||
const s3Descriptor = await smarts3Instance.getS3Descriptor();
|
||||
const smartbucketInstance = new SmartBucket(s3Descriptor);
|
||||
const bucket = await smartbucketInstance.getBucket(bucketName);
|
||||
|
||||
await bucket.getBaseDirectory().fastStore(filePath, fileContent);
|
||||
console.log(`File "${filePath}" uploaded successfully to bucket "${bucketName}".`);
|
||||
}
|
||||
|
||||
startServer()
|
||||
.then(async (smarts3Instance) => {
|
||||
await createBucket(smarts3Instance, 'my-awesome-bucket');
|
||||
await uploadFile(smarts3Instance, 'my-awesome-bucket', 'hello.txt', 'Hello, world!');
|
||||
})
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
### Listing Files in a Bucket
|
||||
|
||||
Listing files within a bucket allows you to manage its contents conveniently:
|
||||
|
||||
```typescript
|
||||
async function listFiles(smarts3Instance: Smarts3, bucketName: string) {
|
||||
const s3Descriptor = await smarts3Instance.getS3Descriptor();
|
||||
const smartbucketInstance = new SmartBucket(s3Descriptor);
|
||||
const bucket = await smartbucketInstance.getBucket(bucketName);
|
||||
|
||||
const baseDirectory = await bucket.getBaseDirectory();
|
||||
const files = await baseDirectory.listFiles();
|
||||
|
||||
console.log(`Files in bucket "${bucketName}":`, files);
|
||||
}
|
||||
|
||||
startServer()
|
||||
.then(async (smarts3Instance) => {
|
||||
await createBucket(smarts3Instance, 'my-awesome-bucket');
|
||||
await listFiles(smarts3Instance, 'my-awesome-bucket');
|
||||
})
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
### Deleting a File
|
||||
|
||||
Managing storage efficiently involves deleting files when necessary:
|
||||
|
||||
```typescript
|
||||
async function deleteFile(smarts3Instance: Smarts3, bucketName: string, filePath: string) {
|
||||
const s3Descriptor = await smarts3Instance.getS3Descriptor();
|
||||
const smartbucketInstance = new SmartBucket(s3Descriptor);
|
||||
const bucket = await smartbucketInstance.getBucket(bucketName);
|
||||
|
||||
await bucket.getBaseDirectory().fastDelete(filePath);
|
||||
console.log(`File "${filePath}" deleted from bucket "${bucketName}".`);
|
||||
}
|
||||
|
||||
startServer()
|
||||
.then(async (smarts3Instance) => {
|
||||
await createBucket(smarts3Instance, 'my-awesome-bucket');
|
||||
await deleteFile(smarts3Instance, 'my-awesome-bucket', 'hello.txt');
|
||||
})
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
### Scenario Integrations
|
||||
|
||||
#### Development and Testing
|
||||
|
||||
1. **Feature Development:** Use `@push.rocks/smarts3` to simulate file upload endpoints, ensuring your application handles file operations correctly before going live.
|
||||
2. **Continuous Integration/Continuous Deployment (CI/CD):** Integrate with CI/CD pipelines to automatically test file interactions.
|
||||
|
||||
3. **Data Migration Testing:** Simulate data migrations between buckets to perfect processes before implementation on actual S3.
|
||||
|
||||
4. **Onboarding New Developers:** Offer new team members hands-on practice with mock setups to improve their understanding without real-world consequences.
|
||||
|
||||
### Stopping the Server
|
||||
|
||||
Safely shutting down the server when tasks are complete ensures system resources are managed well:
|
||||
|
||||
```typescript
|
||||
async function stopServer(smarts3Instance: Smarts3) {
|
||||
await smarts3Instance.stop();
|
||||
console.log('S3 server has been stopped.');
|
||||
}
|
||||
|
||||
startServer()
|
||||
.then(async (smarts3Instance) => {
|
||||
await createBucket(smarts3Instance, 'my-awesome-bucket');
|
||||
await stopServer(smarts3Instance);
|
||||
})
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
In this guide, we walked through setting up and fully utilizing the `@push.rocks/smarts3` package for local development and testing. The package simulates AWS S3 operations, reducing dependency on remote services and allowing efficient development iteration cycles. By implementing the practices and scripts shared here, you can ensure a seamless and productive development experience using the local S3 simulation capabilities of `@push.rocks/smarts3`.
|
||||
|
||||
```
|
||||
|
||||
## 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,3 +1,3 @@
|
||||
import * as smartbucket from '@pushrocks/smartbucket';
|
||||
import * as smartbucket from '@push.rocks/smartbucket';
|
||||
|
||||
export { smartbucket };
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
import * as smarts3 from '../ts/index.js';
|
||||
@ -16,11 +16,14 @@ tap.test('should create a smarts3 instance and run it', async (toolsArg) => {
|
||||
|
||||
tap.test('should be able to access buckets', async () => {
|
||||
const smartbucketInstance = new plugins.smartbucket.SmartBucket(
|
||||
await testSmarts3Instance.getS3Descriptor()
|
||||
await testSmarts3Instance.getS3Descriptor(),
|
||||
);
|
||||
const bucket = await smartbucketInstance.createBucket('testbucket');
|
||||
const baseDirectory = await bucket.getBaseDirectory();
|
||||
await baseDirectory.fastStore('subdir/hello.txt', 'hi there!');
|
||||
await baseDirectory.fastPut({
|
||||
path: 'subdir/hello.txt',
|
||||
contents: 'hi there!',
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should stop the instance', async () => {
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smarts3',
|
||||
version: '2.1.0',
|
||||
description: 'create an s3 endpoint that maps to a local directory'
|
||||
name: '@push.rocks/smarts3',
|
||||
version: '2.2.5',
|
||||
description: 'A Node.js TypeScript package to create a local S3 endpoint for simulating AWS S3 operations using mapped local directories for development and testing purposes.'
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smarts3.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
|
||||
export interface ISmarts3ContructorOptions {
|
||||
@ -42,11 +42,11 @@ export class Smarts3 {
|
||||
console.log('s3 server is running');
|
||||
}
|
||||
|
||||
public async getS3Descriptor(): Promise<plugins.smartbucket.ISmartBucketConfig> {
|
||||
public async getS3Descriptor(): Promise<plugins.tsclass.storage.IS3Descriptor> {
|
||||
return {
|
||||
accessKey: 'S3RVER',
|
||||
accessSecret: 'S3RVER',
|
||||
endpoint: 'localhost',
|
||||
endpoint: '127.0.0.1',
|
||||
port: this.options.port,
|
||||
useSsl: false,
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
import * as plugins from './smarts3.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
'../',
|
||||
);
|
||||
export const nogitDir = plugins.path.join(packageDir, './.nogit');
|
||||
|
||||
|
21
ts/plugins.ts
Normal file
21
ts/plugins.ts
Normal file
@ -0,0 +1,21 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// @push.rocks scope
|
||||
import * as smartbucket from '@push.rocks/smartbucket';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
|
||||
export { smartbucket, smartfile, smartpath };
|
||||
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export { tsclass };
|
||||
|
||||
// thirdparty scope
|
||||
import s3rver from 's3rver';
|
||||
|
||||
export { s3rver };
|
@ -1,16 +0,0 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
|
||||
export { path };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartbucket from '@pushrocks/smartbucket';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartpath from '@pushrocks/smartpath';
|
||||
|
||||
export { smartbucket, smartfile, smartpath };
|
||||
|
||||
// thirdparty scope
|
||||
import s3rver from 's3rver';
|
||||
|
||||
export { s3rver };
|
@ -3,7 +3,14 @@
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext"
|
||||
}
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user