@kravc/dos-dynamodb 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/bin/table.js +22 -1
  2. package/package.json +1 -1
package/bin/table.js CHANGED
@@ -71,12 +71,33 @@ const _reset = async () => {
71
71
  await _create();
72
72
  };
73
73
 
74
- /** Starts dynamodb in the Docker and runs a command. */
74
+ const isMac = process.platform === 'darwin';
75
+ const CONTAINER_NAME = 'dynamo';
76
+ const IMAGE = 'amazon/dynamodb-local:latest';
77
+
78
+ /** Starts dynamodb and runs a command. */
75
79
  const run = async callback => {
76
80
  if (env) {
77
81
  return callback();
78
82
  }
79
83
 
84
+ if (isMac) {
85
+ const { spawnSync, execSync } = require('child_process');
86
+
87
+ const [info] = JSON.parse(spawnSync('container', ['inspect', CONTAINER_NAME], { encoding: 'utf8' }).stdout || '[]');
88
+
89
+ if (info) {
90
+ if (info.status === 'running') {
91
+ return callback();
92
+ }
93
+
94
+ execSync(`container rm ${CONTAINER_NAME}`, { stdio: 'inherit' });
95
+ }
96
+
97
+ execSync(`container run --detach --name ${CONTAINER_NAME} --publish 8000:8000 ${IMAGE}`, { stdio: 'inherit' });
98
+ return callback();
99
+ }
100
+
80
101
  const command = exec('docker compose --project-name dos -f node_modules/@kravc/dos-dynamodb/docker-compose.yaml up -d', callback);
81
102
  command.stdout.on('data', data => console.log(data));
82
103
  command.stderr.on('data', data => console.error(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos-dynamodb",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "CRUD interface for DynamoDB table to be used with @kravc/dos service.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",