@goldstack/template-dynamodb-cli 0.4.1 → 0.4.4

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.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Goldstack DynamoDB Template Tools
1
+ # Goldstack DynamoDB CLI Template Tools
2
2
 
3
- This library provides an API and CLI for building Node.js modules that wrap a DynamoDB Table. These tools allow deploying the infrastructure for the table as well as a way to connect with the table across multiple environments (such as dev, staging and production).
3
+ This library provides a CLI for building Node.js modules that wrap a DynamoDB Table. These tools allow deploying the infrastructure for the table as well as a way to connect with the table across multiple environments (such as dev, staging and production).
4
4
 
5
5
  For more information, see [DynamoDB Template](https://docs.goldstack.party/docs/templates/dynamodb).
@@ -0,0 +1,4 @@
1
+ import { InputMigrations } from 'umzug/lib/types';
2
+ import { DynamoDBContext } from '@goldstack/template-dynamodb';
3
+ export declare const dynamoDBCli: (migrations: InputMigrations<DynamoDBContext>, args: string[]) => Promise<void>;
4
+ //# sourceMappingURL=dynamoDBTableCli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamoDBTableCli.d.ts","sourceRoot":"","sources":["../../src/dynamoDBTableCli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAO/D,eAAO,MAAM,WAAW,eACV,gBAAgB,eAAe,CAAC,QACtC,MAAM,EAAE,KACb,QAAQ,IAAI,CAiCd,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dynamoDBCli = void 0;
4
+ const utils_sh_1 = require("@goldstack/utils-sh");
5
+ const template_dynamodb_1 = require("@goldstack/template-dynamodb");
6
+ const dynamoDBCli = async (migrations, args) => {
7
+ const goldstackConfig = JSON.parse((0, utils_sh_1.read)(`${process.cwd()}/goldstack.json`));
8
+ const packageSchema = JSON.parse((0, utils_sh_1.read)(`${process.cwd()}/schemas/package.schema.json`));
9
+ if (args[0] === 'init') {
10
+ await (0, template_dynamodb_1.connect)({
11
+ goldstackConfig,
12
+ packageSchema,
13
+ migrations,
14
+ deploymentName: args[1],
15
+ });
16
+ return;
17
+ }
18
+ if (args[0] === 'delete') {
19
+ await (0, template_dynamodb_1.deleteTable)({
20
+ goldstackConfig,
21
+ packageSchema,
22
+ deploymentName: args[1],
23
+ });
24
+ return;
25
+ }
26
+ if (args[0] === 'migrate-to') {
27
+ await (0, template_dynamodb_1.migrateDownTo)({
28
+ goldstackConfig,
29
+ packageSchema,
30
+ migrations,
31
+ migrationName: args[2],
32
+ deploymentName: args[1],
33
+ });
34
+ return;
35
+ }
36
+ throw new Error(`Unknown DynamoDB table command: ${args[0]}`);
37
+ };
38
+ exports.dynamoDBCli = dynamoDBCli;
39
+ //# sourceMappingURL=dynamoDBTableCli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamoDBTableCli.js","sourceRoot":"","sources":["../../src/dynamoDBTableCli.ts"],"names":[],"mappings":";;;AAAA,kDAA2C;AAG3C,oEAIsC;AAE/B,MAAM,WAAW,GAAG,KAAK,EAC9B,UAA4C,EAC5C,IAAc,EACC,EAAE;IACjB,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,eAAI,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAC9B,IAAA,eAAI,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,8BAA8B,CAAC,CACrD,CAAC;IACF,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;QACtB,MAAM,IAAA,2BAAO,EAAC;YACZ,eAAe;YACf,aAAa;YACb,UAAU;YACV,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IACD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;QACxB,MAAM,IAAA,+BAAW,EAAC;YAChB,eAAe;YACf,aAAa;YACb,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IACD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,YAAY,EAAE;QAC5B,MAAM,IAAA,iCAAa,EAAC;YAClB,eAAe;YACf,aAAa;YACb,UAAU;YACV,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC;YACtB,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;SACxB,CAAC,CAAC;QACH,OAAO;KACR;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC,CAAC;AApCW,QAAA,WAAW,eAoCtB"}
@@ -0,0 +1,7 @@
1
+ import { InputMigrations } from 'umzug/lib/types';
2
+ import { DynamoDBContext } from '@goldstack/template-dynamodb';
3
+ export declare const run: ({ args, migrations, }: {
4
+ args: string[];
5
+ migrations: InputMigrations<DynamoDBContext>;
6
+ }) => Promise<void>;
7
+ //# sourceMappingURL=templateDynamoDBCli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateDynamoDBCli.d.ts","sourceRoot":"","sources":["../../src/templateDynamoDBCli.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,eAAO,MAAM,GAAG;UAIR,MAAM,EAAE;gBACF,gBAAgB,eAAe,CAAC;MAC1C,QAAQ,IAAI,CA0Ef,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.run = void 0;
7
+ const utils_package_1 = require("@goldstack/utils-package");
8
+ const utils_cli_1 = require("@goldstack/utils-cli");
9
+ const utils_terraform_1 = require("@goldstack/utils-terraform");
10
+ const utils_terraform_aws_1 = require("@goldstack/utils-terraform-aws");
11
+ const utils_package_config_1 = require("@goldstack/utils-package-config");
12
+ const yargs_1 = __importDefault(require("yargs"));
13
+ const assert_1 = __importDefault(require("assert"));
14
+ const dynamoDBTableCli_1 = require("./dynamoDBTableCli");
15
+ const run = async ({ args, migrations, }) => {
16
+ await (0, utils_cli_1.wrapCli)(async () => {
17
+ const deploymentPositional = (yargs) => {
18
+ return yargs.positional('deployment', {
19
+ type: 'string',
20
+ describe: 'Name of the deployment of the table',
21
+ demandOption: true,
22
+ });
23
+ };
24
+ const argv = (0, utils_package_1.buildCli)({
25
+ yargs: yargs_1.default,
26
+ deployCommands: (0, utils_package_1.buildDeployCommands)(),
27
+ infraCommands: (0, utils_terraform_1.infraCommands)(),
28
+ })
29
+ .usage('$0 <table>')
30
+ .command('table <init|delete|migrate-to> <deployment>', 'Utility commands for DynamoDB table', (yargs) => {
31
+ yargs
32
+ .command('init', 'Initialise DynamoDB table and run all applicable migrations', deploymentPositional)
33
+ .command('delete', 'Deletes DynamoDB table and all its data', deploymentPositional)
34
+ .command('migrate-to', 'Migrate DynamoDB table', (yargs) => deploymentPositional(yargs).positional('migration-name', {
35
+ type: 'string',
36
+ describe: 'The name of the migration that the table should be migrated to.',
37
+ demandOption: true,
38
+ }));
39
+ })
40
+ .help().argv;
41
+ const packageConfig = new utils_package_config_1.PackageConfig({
42
+ packagePath: './',
43
+ });
44
+ const config = packageConfig.getConfig();
45
+ (0, assert_1.default)(config, 'DynamoDB package config could not be loaded.');
46
+ const command = argv._[0];
47
+ const [, , , ...opArgs] = args;
48
+ if (command === 'infra') {
49
+ await (0, dynamoDBTableCli_1.dynamoDBCli)(migrations, ['init', opArgs[1]]);
50
+ await (0, utils_terraform_aws_1.terraformAwsCli)(opArgs);
51
+ if (opArgs[0] === 'destroy') {
52
+ await (0, dynamoDBTableCli_1.dynamoDBCli)(migrations, ['delete', opArgs[1]]);
53
+ }
54
+ return;
55
+ }
56
+ if (command === 'deploy') {
57
+ await (0, dynamoDBTableCli_1.dynamoDBCli)(migrations, ['init', opArgs[0]]);
58
+ return;
59
+ }
60
+ if (command === 'table') {
61
+ await (0, dynamoDBTableCli_1.dynamoDBCli)(migrations, opArgs);
62
+ return;
63
+ }
64
+ throw new Error('Unknown command: ' + command);
65
+ });
66
+ };
67
+ exports.run = run;
68
+ //# sourceMappingURL=templateDynamoDBCli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateDynamoDBCli.js","sourceRoot":"","sources":["../../src/templateDynamoDBCli.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAyE;AACzE,oDAA+C;AAC/C,gEAA2D;AAC3D,wEAAiE;AACjE,0EAAgE;AAKhE,kDAAoC;AACpC,oDAA4B;AAC5B,yDAAiD;AAI1C,MAAM,GAAG,GAAG,KAAK,EAAE,EACxB,IAAI,EACJ,UAAU,GAIX,EAAiB,EAAE;IAClB,MAAM,IAAA,mBAAO,EAAC,KAAK,IAAI,EAAE;QACvB,MAAM,oBAAoB,GAAG,CAAC,KAAgB,EAAa,EAAE;YAC3D,OAAO,KAAK,CAAC,UAAU,CAAC,YAAY,EAAE;gBACpC,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,qCAAqC;gBAC/C,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC,CAAC;QACF,MAAM,IAAI,GAAG,IAAA,wBAAQ,EAAC;YACpB,KAAK,EAAL,eAAK;YACL,cAAc,EAAE,IAAA,mCAAmB,GAAE;YACrC,aAAa,EAAE,IAAA,+BAAa,GAAE;SAC/B,CAAC;aACC,KAAK,CAAC,YAAY,CAAC;aACnB,OAAO,CACN,6CAA6C,EAC7C,qCAAqC,EACrC,CAAC,KAAK,EAAE,EAAE;YACR,KAAK;iBACF,OAAO,CACN,MAAM,EACN,6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C;YACnD,OAAO;SACR;QAED,IAAI,OAAO,KAAK,OAAO,EAAE;YACvB,MAAM,IAAA,8BAAW,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YACtC,OAAO;SACR;QAED,MAAM,IAAI,KAAK,CAAC,mBAAmB,GAAG,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAhFW,QAAA,GAAG,OAgFd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goldstack/template-dynamodb-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.4",
4
4
  "description": "Utilities for building modules for DynamoDB access.",
5
5
  "keywords": [
6
6
  "goldstack",
@@ -38,27 +38,27 @@
38
38
  "version:apply:force": "yarn version $@ && yarn version apply"
39
39
  },
40
40
  "dependencies": {
41
- "@goldstack/template-dynamodb": "0.1.11",
42
- "@goldstack/utils-cli": "0.2.13",
43
- "@goldstack/utils-package": "0.3.38",
44
- "@goldstack/utils-package-config": "0.3.39",
45
- "@goldstack/utils-sh": "0.4.31",
46
- "@goldstack/utils-terraform": "0.3.68",
47
- "@goldstack/utils-terraform-aws": "0.3.67",
41
+ "@goldstack/template-dynamodb": "0.1.13",
42
+ "@goldstack/utils-cli": "0.2.14",
43
+ "@goldstack/utils-package": "0.3.39",
44
+ "@goldstack/utils-package-config": "0.3.40",
45
+ "@goldstack/utils-sh": "0.4.32",
46
+ "@goldstack/utils-terraform": "0.3.69",
47
+ "@goldstack/utils-terraform-aws": "0.3.68",
48
48
  "umzug": "^3.1.1",
49
49
  "yargs": "^15.4.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@goldstack/utils-docs-cli": "0.3.11",
53
- "@goldstack/utils-git": "0.1.34",
54
- "@goldstack/utils-package-config-generate": "0.2.14",
53
+ "@goldstack/utils-git": "0.1.35",
54
+ "@goldstack/utils-package-config-generate": "0.2.15",
55
55
  "@types/jest": "^27.5.1",
56
56
  "@types/node": "^17.0.33",
57
57
  "@types/yargs": "^15.0.5",
58
58
  "jest": "^28.1.0",
59
59
  "rimraf": "^3.0.2",
60
60
  "ts-jest": "^28.0.2",
61
- "ts-node": "^10.7.0",
61
+ "ts-node": "^10.8.0",
62
62
  "typescript": "^4.6.4"
63
63
  },
64
64
  "publishConfig": {