mongo-seeding-cli
Advanced tools
Comparing version 3.7.2 to 3.8.0-alpha.0
@@ -22,2 +22,3 @@ "use strict"; | ||
this.run = () => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b; | ||
let options; | ||
@@ -44,3 +45,3 @@ try { | ||
try { | ||
const collections = seeder.readCollectionsFromPath((0, path_1.resolve)(config.cli.dataPath), config.collectionReading); | ||
const collections = seeder.readCollectionsFromPath((0, path_1.resolve)((_b = (_a = config.cli) === null || _a === void 0 ? void 0 : _a.dataPath) !== null && _b !== void 0 ? _b : './'), config.collectionReading); | ||
yield seeder.import(collections); | ||
@@ -47,0 +48,0 @@ } |
@@ -9,2 +9,4 @@ import { CommandLineOption, CommandLineArguments, PartialCliOptions } from './types'; | ||
export declare const DB_OPTIONS_KEY_VALUE_SEPARATOR = "="; | ||
export declare function convertEmptyObjectToUndefined(obj: any): object | undefined; | ||
export declare function convertEmptyObjectToUndefined(obj: { | ||
[key: string]: unknown; | ||
}): object | undefined; |
@@ -222,3 +222,3 @@ "use strict"; | ||
for (const key in obj) { | ||
if (obj.hasOwnProperty(key) && typeof obj[key] !== 'undefined') { | ||
if (typeof obj[key] !== 'undefined') { | ||
return obj; | ||
@@ -225,0 +225,0 @@ } |
@@ -31,3 +31,3 @@ import { SeederConfig, SeederCollectionReadingOptions } from 'mongo-seeding'; | ||
} | ||
interface CliOptions { | ||
export interface CliOptions { | ||
seeder: SeederConfig; | ||
@@ -37,3 +37,3 @@ collectionReading: SeederCollectionReadingOptions; | ||
} | ||
export declare type PartialCliOptions = DeepPartial<CliOptions>; | ||
export type PartialCliOptions = DeepPartial<CliOptions>; | ||
export interface CliSpecificOptions { | ||
@@ -47,2 +47,1 @@ dataPath: string; | ||
} | ||
export {}; |
{ | ||
"name": "mongo-seeding-cli", | ||
"description": "The ultimate command line tool for populating your MongoDB database.", | ||
"version": "3.7.2", | ||
"homepage": "https://mongo-seeding.kosiec.dev", | ||
"version": "3.8.0-alpha.0", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Paweł Kosiec", | ||
"email": "pawel@kosiec.dev", | ||
"url": "https://kosiec.dev" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Paweł Kosiec", | ||
"email": "pawel@kosiec.dev", | ||
"url": "https://kosiec.dev" | ||
} | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pkosiec/mongo-seeding.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/pkosiec/mongo-seeding/issues" | ||
}, | ||
"keywords": [ | ||
@@ -36,14 +56,2 @@ "mongo", | ||
], | ||
"author": { | ||
"name": "Paweł Kosiec", | ||
"email": "pawel@kosiec.net", | ||
"url": "https://kosiec.net" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pkosiec/mongo-seeding" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/pkosiec/mongo-seeding/issues" | ||
}, | ||
"main": "dist/index.js", | ||
@@ -69,7 +77,7 @@ "files": [ | ||
"command-line-args": "^5.1.1", | ||
"command-line-usage": "^6.1.1", | ||
"command-line-usage": "^7.0.1", | ||
"extend": "^3.0.2", | ||
"mongo-seeding": "^3.7.2", | ||
"mongo-seeding": "^3.8.0-alpha.0", | ||
"ts-node": "^10.3.0", | ||
"typescript": "^4.4.4" | ||
"typescript": "^5.2.2" | ||
}, | ||
@@ -79,8 +87,7 @@ "devDependencies": { | ||
"@types/extend": "^3.0.1", | ||
"@types/jest": "^27.0.2", | ||
"@types/mongodb": "^3.6.20", | ||
"@types/node": "^17.0.23", | ||
"jest": "^28.1.0", | ||
"mongodb": "3.6.11", | ||
"ts-jest": "^28.0.3" | ||
"@types/jest": "^29.0.3", | ||
"@types/node": "^20.8.0", | ||
"jest": "^29.1.1", | ||
"mongodb": "^6.1.0", | ||
"ts-jest": "^29.1.1" | ||
}, | ||
@@ -111,3 +118,3 @@ "jest": { | ||
}, | ||
"gitHead": "574803bdd4e0ee27840d1a182538a78e0c6ce7fe" | ||
"gitHead": "49ebbaf40bca10935b52941cae22e8a11595626f" | ||
} |
102
README.md
@@ -7,3 +7,3 @@ ![Mongo Seeding](https://raw.githubusercontent.com/pkosiec/mongo-seeding/main/docs/assets/logo.png) | ||
The ultimate CLI tool for populating your MongoDB database :rocket: | ||
The ultimate CLI tool for populating your MongoDB database :rocket: | ||
@@ -25,19 +25,19 @@ Define MongoDB documents in JSON, JavaScript or even TypeScript file(s). Import them with command line interface. | ||
```bash | ||
seed | ||
``` | ||
```bash | ||
seed | ||
``` | ||
1. You can specify custom settings with command line parameters. The following example imports data from `./example/data` directory using MongoDB connection URI `mongodb://127.0.0.1:27017/mydb` with option to drop database before import: | ||
```bash | ||
seed -u 'mongodb://127.0.0.1:27017/mydb' --drop-database ./example/data | ||
``` | ||
```bash | ||
seed -u 'mongodb://127.0.0.1:27017/mydb' --drop-database ./example/data | ||
``` | ||
You can also use environmental variables to configure the CLI. For example: | ||
You can also use environmental variables to configure the CLI. For example: | ||
```bash | ||
DB_URI='mongodb://127.0.0.1:27017/mydb' DROP_DATABASE=true seed ./example/data | ||
``` | ||
```bash | ||
DB_URI='mongodb://127.0.0.1:27017/mydb' DROP_DATABASE=true seed ./example/data | ||
``` | ||
Full configuration options are described in [Configuration](#configuration) section. | ||
Full configuration options are described in [Configuration](#configuration) section. | ||
@@ -54,23 +54,23 @@ ## Configuration | ||
| Name | Default Value | Description | | ||
|-------------|----------------|---------------------| | ||
| `{PATH}` | current directory | Path to directory containing import data | | ||
| `--db-uri {URI}` or `-u {URI}` | *`undefined`* | If defined, the URI will be used for establishing connection to database, ignoring values defined via other `db-*` parameters (e.g. `db-name`, `db-host`, etc.) | ||
| `--db-protocol {DB_PROTOCOL}` | `mongodb` | MongoDB database protocol | | ||
| `--db-host {DB_HOST}` | `127.0.0.1` | MongoDB database host | | ||
| `--db-port {DB_PORT}` | `27017` | MongoDB database port | | ||
| `--db-name {DB_NAME}` | `database` | Name of the database | | ||
| `--db-username {DB_USERNAME}` | *`undefined`* | Username for connecting with database that requires authentication | | ||
| `--db-password {DB_PASSWORD}` | *`undefined`* | Password for connecting with database that requires authentication | | ||
| `--db-options` | *`undefined`* | [MongoDB connection options](https://docs.mongodb.com/manual/reference/connection-string/) in a form of multiple `{key}={value}` values, separated by semicolon. For example: `ssl=true;maxPoolSize=50` | | ||
| `--drop-database` | `false` | Drops entire database before data import | | ||
| `--drop-collections` | `false` | Drops every collection which is being imported | | ||
| `--remove-all-documents` | `false` | Delete all documents from every collection that is being imported | | ||
| `--replace-id` | `false` | Replaces `id` property with `_id` for every document during data import | | ||
| `--set-timestamps` | `false` | Sets `createdAt` and `updatedAt` timestamps for every document during data import | | ||
| `--reconnect-timeout` | `10000` | Maximum time in milliseconds of waiting for successful MongoDB connection | | ||
| `--ejson-parse-canonical-mode` | `false` | Enables [EJSON Canonical Mode](https://docs.mongodb.com/manual/reference/mongodb-extended-json/) for all parsed `.json` files. By default the EJSON Relaxed mode is enabled. | | ||
| `--transpile-only` | `false` | Disables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import | | ||
| `--silent` or `-s` | `false` | Disables printing logging of Mongo Seeding status to standard output | | ||
| `--help` or `-h` | n/a | Help | ||
| Name | Default Value | Description | | ||
| ------------------------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `{PATH}` | current directory | Path to directory containing import data | | ||
| `--db-uri {URI}` or `-u {URI}` | _`undefined`_ | If defined, the URI will be used for establishing connection to database, ignoring values defined via other `db-*` parameters (e.g. `db-name`, `db-host`, etc.) | | ||
| `--db-protocol {DB_PROTOCOL}` | `mongodb` | MongoDB database protocol | | ||
| `--db-host {DB_HOST}` | `127.0.0.1` | MongoDB database host | | ||
| `--db-port {DB_PORT}` | `27017` | MongoDB database port | | ||
| `--db-name {DB_NAME}` | `database` | Name of the database | | ||
| `--db-username {DB_USERNAME}` | _`undefined`_ | Username for connecting with database that requires authentication | | ||
| `--db-password {DB_PASSWORD}` | _`undefined`_ | Password for connecting with database that requires authentication | | ||
| `--db-options` | _`undefined`_ | [MongoDB connection options](https://docs.mongodb.com/manual/reference/connection-string/) in a form of multiple `{key}={value}` values, separated by semicolon. For example: `ssl=true;maxPoolSize=50` | | ||
| `--drop-database` | `false` | Drops entire database before data import | | ||
| `--drop-collections` | `false` | Drops every collection which is being imported | | ||
| `--remove-all-documents` | `false` | Delete all documents from every collection that is being imported | | ||
| `--replace-id` | `false` | Replaces `id` property with `_id` for every document during data import | | ||
| `--set-timestamps` | `false` | Sets `createdAt` and `updatedAt` timestamps for every document during data import | | ||
| `--reconnect-timeout` | `10000` | Maximum time in milliseconds of waiting for successful MongoDB connection | | ||
| `--ejson-parse-canonical-mode` | `false` | Enables [EJSON Canonical Mode](https://docs.mongodb.com/manual/reference/mongodb-extended-json/) for all parsed `.json` files. By default the EJSON Relaxed mode is enabled. | | ||
| `--transpile-only` | `false` | Disables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import | | ||
| `--silent` or `-s` | `false` | Disables printing logging of Mongo Seeding status to standard output | | ||
| `--help` or `-h` | n/a | Help | | ||
@@ -81,19 +81,19 @@ ## Environmental variables | ||
| Name | Default Value | Description | | ||
|-------------|----------------|---------------------| | ||
| `DB_URI` | *`undefined`* | If defined, the URI is used for establishing connection to database, ignoring values given in `DB_*` environmental variables (e.g. `DB_HOST`, `DB_PORT`, etc.). | ||
| `DB_HOST` | `127.0.0.1` | MongoDB database host | | ||
| `DB_PORT` | `27017` | MongoDB database port | | ||
| `DB_NAME` | `database` | Name of the database | | ||
| `DB_USERNAME` | *`undefined`* | Username for connecting with database that requires authentication | | ||
| `DB_PASSWORD` | *`undefined`* | Password for connecting with database that requires authentication | | ||
| `DB_OPTIONS` | *`undefined`* | [MongoDB connection options](https://docs.mongodb.com/manual/reference/connection-string/) in a form of multiple `{key}={value}` values, separated by semicolon. For example: `ssl=true;maxPoolSize=50`. | | ||
| `DROP_DATABASE` | `false` | Drops entire database before data import | | ||
| `DROP_COLLECTIONS` | `false` | Drops every collection which is being imported | | ||
| `REMOVE_ALL_DOCUMENTS` | `false` | Delete all documents from every collection that is being imported | | ||
| `REPLACE_ID` | `false` | Replaces `id` property with `_id` for every document during import; useful for ORMs | | ||
| `SET_TIMESTAMPS` | `false` | Sets `createdAt` and `updatedAt` timestamps for every document during data import | | ||
| `RECONNECT_TIMEOUT` | `10000` | Maximum time in milliseconds of waiting for successful MongoDB connection | | ||
| `EJSON_PARSE_CANONICAL_MODE` | `false` | Enables [EJSON Canonical Mode](https://docs.mongodb.com/manual/reference/mongodb-extended-json/) for all parsed `.json` files. By default the EJSON Relaxed mode is enabled. | | ||
| `TRANSPILE_ONLY` | `false` | Disables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import | | ||
| `SILENT` | `false` | Disables printing logging of Mongo Seeding status to standard output | | ||
| Name | Default Value | Description | | ||
| ---------------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `DB_URI` | _`undefined`_ | If defined, the URI is used for establishing connection to database, ignoring values given in `DB_*` environmental variables (e.g. `DB_HOST`, `DB_PORT`, etc.). | | ||
| `DB_HOST` | `127.0.0.1` | MongoDB database host | | ||
| `DB_PORT` | `27017` | MongoDB database port | | ||
| `DB_NAME` | `database` | Name of the database | | ||
| `DB_USERNAME` | _`undefined`_ | Username for connecting with database that requires authentication | | ||
| `DB_PASSWORD` | _`undefined`_ | Password for connecting with database that requires authentication | | ||
| `DB_OPTIONS` | _`undefined`_ | [MongoDB connection options](https://docs.mongodb.com/manual/reference/connection-string/) in a form of multiple `{key}={value}` values, separated by semicolon. For example: `ssl=true;maxPoolSize=50`. | | ||
| `DROP_DATABASE` | `false` | Drops entire database before data import | | ||
| `DROP_COLLECTIONS` | `false` | Drops every collection which is being imported | | ||
| `REMOVE_ALL_DOCUMENTS` | `false` | Delete all documents from every collection that is being imported | | ||
| `REPLACE_ID` | `false` | Replaces `id` property with `_id` for every document during import; useful for ORMs | | ||
| `SET_TIMESTAMPS` | `false` | Sets `createdAt` and `updatedAt` timestamps for every document during data import | | ||
| `RECONNECT_TIMEOUT` | `10000` | Maximum time in milliseconds of waiting for successful MongoDB connection | | ||
| `EJSON_PARSE_CANONICAL_MODE` | `false` | Enables [EJSON Canonical Mode](https://docs.mongodb.com/manual/reference/mongodb-extended-json/) for all parsed `.json` files. By default the EJSON Relaxed mode is enabled. | | ||
| `TRANSPILE_ONLY` | `false` | Disables type checking on TypeScript files import. This option vastly improves performance of TypeScript data import | | ||
| `SILENT` | `false` | Disables printing logging of Mongo Seeding status to standard output | |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
40975
7
415
96
1
+ Added@75lb/deep-merge@1.1.1(transitive)
+ Added@mongodb-js/saslprep@1.1.5(transitive)
+ Added@types/webidl-conversions@7.0.3(transitive)
+ Added@types/whatwg-url@11.0.4(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedarray-back@6.2.2(transitive)
+ Addedbson@6.6.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchalk-template@0.4.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcommand-line-usage@7.0.1(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedlodash.assignwith@4.2.0(transitive)
+ Addedmongo-seeding@3.8.0-alpha.0(transitive)
+ Addedmongodb@6.5.0(transitive)
+ Addedmongodb-connection-string-url@3.0.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedstream-read-all@3.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtable-layout@3.0.2(transitive)
+ Addedtr46@4.1.1(transitive)
+ Addedtypescript@5.4.5(transitive)
+ Addedtypical@7.1.1(transitive)
+ Addedwebidl-conversions@7.0.0(transitive)
+ Addedwhatwg-url@13.0.0(transitive)
+ Addedwordwrapjs@5.1.0(transitive)
- Removed@types/bson@4.2.0(transitive)
- Removed@types/mongodb@3.6.20(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedarray-back@4.0.2(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbl@2.2.1(transitive)
- Removedbson@1.1.64.7.2(transitive)
- Removedbuffer@5.7.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcommand-line-usage@6.1.3(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddeep-extend@0.6.0(transitive)
- Removeddenque@1.5.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedisarray@1.0.0(transitive)
- Removedmongo-seeding@3.7.2(transitive)
- Removedmongodb@3.7.4(transitive)
- Removedoptional-require@1.1.8(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreduce-flatten@2.0.0(transitive)
- Removedrequire-at@1.0.6(transitive)
- Removedsafe-buffer@5.1.25.2.1(transitive)
- Removedsaslprep@1.0.3(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable-layout@1.0.2(transitive)
- Removedtypescript@4.9.5(transitive)
- Removedtypical@5.2.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwordwrapjs@4.0.1(transitive)
Updatedcommand-line-usage@^7.0.1
Updatedmongo-seeding@^3.8.0-alpha.0
Updatedtypescript@^5.2.2