@push.rocks/smartmongo 2.0.10 → 2.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export declare const commitinfo: {
5
5
  name: string;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartmongo',
6
- version: '2.0.10',
7
- description: 'create a local mongodb for testing'
6
+ version: '2.0.11',
7
+ description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
8
8
  };
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG9DQUFvQztDQUNsRCxDQUFBIn0=
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFFBQVE7SUFDakIsV0FBVyxFQUFFLG1GQUFtRjtDQUNqRyxDQUFBIn0=
package/npmextra.json CHANGED
@@ -2,17 +2,29 @@
2
2
  "gitzone": {
3
3
  "projectType": "npm",
4
4
  "module": {
5
- "githost": "gitlab.com",
5
+ "githost": "code.foss.global",
6
6
  "gitscope": "push.rocks",
7
7
  "gitrepo": "smartmongo",
8
- "description": "create a local mongodb for testing",
8
+ "description": "A module for creating and managing a local MongoDB instance for testing purposes.",
9
9
  "npmPackagename": "@push.rocks/smartmongo",
10
10
  "license": "MIT",
11
- "projectDomain": "push.rocks"
11
+ "projectDomain": "push.rocks",
12
+ "keywords": [
13
+ "mongodb",
14
+ "testing",
15
+ "local database",
16
+ "replica set",
17
+ "memory server",
18
+ "database management",
19
+ "typescript"
20
+ ]
12
21
  }
13
22
  },
14
23
  "npmci": {
15
24
  "npmGlobalTools": [],
16
25
  "npmAccessLevel": "public"
26
+ },
27
+ "tsdoc": {
28
+ "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"
17
29
  }
18
30
  }
package/package.json CHANGED
@@ -1,32 +1,27 @@
1
1
  {
2
2
  "name": "@push.rocks/smartmongo",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "private": false,
5
- "description": "create a local mongodb for testing",
5
+ "description": "A module for creating and managing a local MongoDB instance for testing purposes.",
6
6
  "main": "dist_ts/index.js",
7
7
  "typings": "dist_ts/index.d.ts",
8
8
  "type": "module",
9
9
  "author": "Lossless GmbH",
10
10
  "license": "MIT",
11
- "scripts": {
12
- "test": "(tstest test/ --web)",
13
- "build": "(tsbuild --web --allowimplicitany)",
14
- "buildDocs": "tsdoc"
15
- },
16
11
  "devDependencies": {
17
- "@gitzone/tsbuild": "^2.1.66",
18
- "@gitzone/tsbundle": "^2.0.8",
19
- "@gitzone/tsrun": "^1.2.44",
20
- "@gitzone/tstest": "^1.0.77",
12
+ "@git.zone/tsbuild": "^2.1.66",
13
+ "@git.zone/tsbundle": "^2.0.8",
14
+ "@git.zone/tsrun": "^1.2.44",
15
+ "@git.zone/tstest": "^1.0.77",
21
16
  "@push.rocks/tapbundle": "^5.0.12",
22
- "@types/node": "^20.4.8"
17
+ "@types/node": "^22.14.0"
23
18
  },
24
19
  "dependencies": {
25
20
  "@push.rocks/mongodump": "^1.0.7",
26
21
  "@push.rocks/smartdata": "^5.0.23",
27
22
  "@push.rocks/smartpath": "^5.0.11",
28
23
  "@push.rocks/smartpromise": "^4.0.3",
29
- "mongodb-memory-server": "^8.14.0"
24
+ "mongodb-memory-server": "^10.1.4"
30
25
  },
31
26
  "browserslist": [
32
27
  "last 1 chrome versions"
@@ -42,5 +37,24 @@
42
37
  "cli.js",
43
38
  "npmextra.json",
44
39
  "readme.md"
45
- ]
46
- }
40
+ ],
41
+ "keywords": [
42
+ "mongodb",
43
+ "testing",
44
+ "local database",
45
+ "replica set",
46
+ "memory server",
47
+ "database management",
48
+ "typescript"
49
+ ],
50
+ "homepage": "https://code.foss.global/push.rocks/smartmongo",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "https://code.foss.global/push.rocks/smartmongo.git"
54
+ },
55
+ "scripts": {
56
+ "test": "(tstest test/ --web)",
57
+ "build": "(tsbuild --web --allowimplicitany)",
58
+ "buildDocs": "tsdoc"
59
+ }
60
+ }
@@ -0,0 +1 @@
1
+
package/readme.md CHANGED
@@ -1,37 +1,103 @@
1
1
  # @push.rocks/smartmongo
2
2
  create a local mongodb for testing
3
3
 
4
- ## Availabililty and Links
5
- * [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartmongo)
6
- * [gitlab.com (source)](https://gitlab.com/push.rocks/smartmongo)
7
- * [github.com (source mirror)](https://github.com/push.rocks/smartmongo)
8
- * [docs (typedoc)](https://push.rocks.gitlab.io/smartmongo/)
9
-
10
- ## Status for master
11
-
12
- Status Category | Status Badge
13
- -- | --
14
- GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartmongo/badges/master/pipeline.svg)](https://lossless.cloud)
15
- GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartmongo/badges/master/coverage.svg)](https://lossless.cloud)
16
- npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartmongo)](https://lossless.cloud)
17
- Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartmongo)](https://lossless.cloud)
18
- TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
- node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
- Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
- PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartmongo)](https://lossless.cloud)
22
- PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartmongo)](https://lossless.cloud)
23
- BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartmongo)](https://lossless.cloud)
4
+ ## Install
5
+
6
+ To start using @push.rocks/smartmongo in your project, you first need to install it via npm. You can do this by running the following command in your terminal:
7
+
8
+ ```bash
9
+ npm install @push.rocks/smartmongo --save-dev
10
+ ```
11
+
12
+ This will add `@push.rocks/smartmongo` as a development dependency to your project because it's typically used for testing purposes.
24
13
 
25
14
  ## Usage
26
15
 
27
- Use TypeScript for best in class intellisense
16
+ The `@push.rocks/smartmongo` package provides a convenient way to spin up a local MongoDB instance, primarily for testing purposes. It's designed to simplify the process of configuring and managing a MongoDB replica set during development or in CI/CD pipelines. Below, we present a comprehensive guide on how to utilize the full feature set of this module, employing ESM syntax and TypeScript.
17
+
18
+ ### Setting Up
19
+
20
+ To get started, you must first import the `SmartMongo` class from the package. This class is responsible for handling the MongoDB instances.
21
+
22
+ ```typescript
23
+ import { SmartMongo } from '@push.rocks/smartmongo';
24
+ ```
25
+
26
+ ### Creating and Starting a MongoDB Instance
27
+
28
+ With `SmartMongo`, you can easily create and start a MongoDB replica set. You can specify the number of replica instances; however, if not specified, it defaults to 1.
29
+
30
+ ```typescript
31
+ async function setupMongoDB() {
32
+ const smartMongoInstance = await SmartMongo.createAndStart(1); // Number of replicas is optional
33
+ return smartMongoInstance;
34
+ }
35
+
36
+ const myDbInstance = await setupMongoDB();
37
+ ```
38
+
39
+ After invoking `createAndStart`, an instance of MongoDB is spun up and is ready for use. The `createAndStart` function returns a `SmartMongo` instance which can be interacted with for further operations.
40
+
41
+ ### Accessing MongoDB Connection Information
42
+
43
+ After instantiation, you might want to connect your application or test suite to the MongoDB instance. The `getMongoDescriptor` method facilitates this by providing essential connection details.
44
+
45
+ ```typescript
46
+ const mongoDescriptor = await myDbInstance.getMongoDescriptor();
47
+ console.log(mongoDescriptor.mongoDbUrl); // Use this URL to connect with Mongoose or MongoDB clients.
48
+ ```
49
+
50
+ ### Stopping and Cleaning Up
51
+
52
+ Once your tests have completed or you're done using the MongoDB instance, it’s crucial to properly stop and clean up the resources. `@push.rocks/smartmongo` provides two methods for this purpose:
53
+
54
+ 1. **stop()**: Stops the MongoDB instance without persisting any data.
55
+
56
+ ```typescript
57
+ await myDbInstance.stop();
58
+ ```
59
+
60
+ 2. **stopAndDumpToDir(dirPath)**: Stops the MongoDB instance and persists the data to the specified directory. This is useful if you need to examine the data post-test or reuse it in subsequent runs.
61
+
62
+ ```typescript
63
+ await myDbInstance.stopAndDumpToDir('./path/to/dump');
64
+ ```
65
+
66
+ ### Advanced Usage
67
+
68
+ `@push.rocks/smartmongo` also provides advanced features for dumping the database and configuring MongoDB replica sets. These features can be particularly useful for complex testing scenarios or when specific MongoDB behaviors need to be emulated.
69
+
70
+ #### Dumping Data
71
+
72
+ To dump the MongoDB data for inspection or backup purposes, use the `stopAndDumpToDir` method. This method optionally takes a function to customize the naming scheme of the dumped files based on the document content.
73
+
74
+ ```typescript
75
+ await myDbInstance.stopAndDumpToDir('./path/to/dump', (doc) => {
76
+ return `customNameBasedOnDoc-${doc._id}.bson`;
77
+ });
78
+ ```
79
+
80
+ Using `@push.rocks/smartmongo` significantly simplifies the process of managing MongoDB instances for local testing environments. It abstracts away the complexity of starting, operating, and tearing down MongoDB replica sets, allowing developers to focus on building and testing their applications.
81
+
82
+ ### Conclusion
83
+
84
+ `@push.rocks/smartmongo` serves as a powerful tool in a developer's arsenal for efficiently configuring, running, and managing MongoDB instances in testing scenarios. By following the above guide, developers can leverage MongoDB in their projects with minimal setup and gain valuable insights into their applications' data interactions in a controlled and reproducible environment.
85
+
86
+ ## License and Legal Information
87
+
88
+ 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.
89
+
90
+ **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.
91
+
92
+ ### Trademarks
93
+
94
+ 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.
28
95
 
29
- ## Contribution
96
+ ### Company Information
30
97
 
31
- 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). :)
98
+ Task Venture Capital GmbH
99
+ Registered at District court Bremen HRB 35230 HB, Germany
32
100
 
33
- For further information read the linked docs at the top of this readme.
101
+ For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
34
102
 
35
- ## Legal
36
- > MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
37
- | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
103
+ 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,8 +1,8 @@
1
1
  /**
2
- * autocreated commitinfo by @pushrocks/commitinfo
2
+ * autocreated commitinfo by @push.rocks/commitinfo
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartmongo',
6
- version: '2.0.10',
7
- description: 'create a local mongodb for testing'
6
+ version: '2.0.11',
7
+ description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
8
8
  }