@aptos-scp/isl-component-resource-definition 1.0.0

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/LICENSE.md ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2025 Aptos, Inc. All rights reserved.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # isl-component-resource-definition
2
+
3
+ Component is used to automate the initialization of AWS resources, specifically AWS EventBridge, based on user-defined metadata.
4
+
5
+ ## Establish environment variables (workstation installation)
6
+
7
+ Copy the .env.example file with default/sample environment variables for development to .env.
8
+ Examine the variables and edit as necessary/appropriate for your workstation environment.
9
+
10
+ ```
11
+ cp .env.example .env
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ First, make sure you are logged-in to the private NPM registry:
17
+
18
+ ```
19
+ npm adduser --registry=https://registry.npmjs.org/ --scope=@aptos-scp
20
+ ```
21
+
22
+ Then install the dependency packages:
23
+
24
+ ```
25
+ npm install
26
+ ```
27
+
28
+ ## Building the component library
29
+
30
+ First, make sure you've followed the instructions in the [Installation](installation) section so you're logged into the
31
+ private NPM registry and have installed dependency packages.
32
+
33
+ Then, to build the component library:
34
+
35
+ ```
36
+ $ npm run build
37
+ ```
38
+
39
+ You can then also run tests and coverage:
40
+
41
+ ```
42
+ $ npm run test
43
+ $ npm run test:ci
44
+ ```
45
+
46
+ ## Publishing changes
47
+
48
+ To publish a new version to the NPM registry:
49
+
50
+ 1. Do these steps only on the master branch -- that is, not on a feature branch. Feature branches should be
51
+ merged to master before these steps.
52
+
53
+ 1. Commit and push the changes (on master).
54
+
55
+ 1. Update the version of the package using one of the following:
56
+
57
+ ```
58
+ npm version patch
59
+ ```
60
+
61
+ or
62
+
63
+ ```
64
+ npm version minor
65
+ ```
66
+
67
+ or one of the other variations (see [npm-version](https://docs.npmjs.com/cli/version))
68
+
69
+ 1. Push the version commit and all version tags to trigger the CircleCI build that will build and publish the updated component:
70
+
71
+ ```
72
+ git push origin master --follow-tags
73
+ ```
74
+
75
+ or
76
+
77
+ From WebStorm or IntelliJ make sure that the Push Tags check-box is checked, when you push changes.
78
+
79
+ When the build in Circle CI sees the version tag, it will publish the changes to the NPM repository.
80
+
81
+ ## License
82
+
83
+ Please see [LICENSE.md](LICENSE.md).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const dotenv = require("dotenv");
5
+ const ResourceDefinitionFactory_1 = require("../factories/ResourceDefinitionFactory");
6
+ dotenv.config();
7
+ const [command, ...args] = process.argv.slice(2);
8
+ const resourceDefinition = ResourceDefinitionFactory_1.ResourceDefinitionFactory.create("sam");
9
+ resourceDefinition
10
+ .execute(command, args)
11
+ .then(() => {
12
+ console.log("Command executed successfully.");
13
+ })
14
+ .catch((error) => {
15
+ console.error("Error executing command:", error);
16
+ process.exit(1);
17
+ });
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import { IResourceDefinition } from "../interfaces/IResourceDefinition";
2
+ export declare class ResourceDefinitionFactory {
3
+ static create(type: string): IResourceDefinition;
4
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResourceDefinitionFactory = void 0;
4
+ const SamResourceDefinition_1 = require("../implementations/SamResourceDefinition");
5
+ class ResourceDefinitionFactory {
6
+ static create(type) {
7
+ if (type === "sam") {
8
+ return new SamResourceDefinition_1.SamResourceDefinition();
9
+ }
10
+ else {
11
+ throw new Error(`Unknown resource definition type: ${type}`);
12
+ }
13
+ }
14
+ }
15
+ exports.ResourceDefinitionFactory = ResourceDefinitionFactory;
16
+ //# sourceMappingURL=ResourceDefinitionFactory.js.map
@@ -0,0 +1,5 @@
1
+ import { IResourceDefinition } from "../interfaces/IResourceDefinition";
2
+ export declare class SamResourceDefinition implements IResourceDefinition {
3
+ execute(inputCommand: string, args: string[]): Promise<void>;
4
+ private evaluateEnvVars;
5
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SamResourceDefinition = void 0;
13
+ const util = require("util");
14
+ const child_process_1 = require("child_process");
15
+ class SamResourceDefinition {
16
+ execute(inputCommand, args) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const execPromise = util.promisify(child_process_1.exec);
19
+ const evaluatedArgs = this.evaluateEnvVars(args);
20
+ const samCommand = `sam ${inputCommand} ${evaluatedArgs.join(" ")}`;
21
+ console.log(`Executing command: ${samCommand}`);
22
+ const { stdout, stderr } = yield execPromise(samCommand);
23
+ console.log(`SAM Execute Output: ${stdout}`);
24
+ if (stderr) {
25
+ console.error(`SAM Execute Error: ${stderr}`);
26
+ }
27
+ });
28
+ }
29
+ evaluateEnvVars(args) {
30
+ return args.map((arg) => {
31
+ if (arg.startsWith("%") && arg.endsWith("%")) {
32
+ const envVar = arg.slice(1, -1);
33
+ return process.env[envVar] || "";
34
+ }
35
+ return arg;
36
+ });
37
+ }
38
+ }
39
+ exports.SamResourceDefinition = SamResourceDefinition;
40
+ //# sourceMappingURL=SamResourceDefinition.js.map
@@ -0,0 +1,3 @@
1
+ export interface IResourceDefinition {
2
+ execute(inputCommand: string, args: string[]): Promise<void>;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IResourceDefinition.js.map
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@aptos-scp/isl-component-resource-definition",
3
+ "version": "1.0.0",
4
+ "description": "Component is used to create Serverless application",
5
+ "private": false,
6
+ "license": "SEE LICENSE IN LICENSE.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://bitbucket.org/aptosretail/isl-component-resource-definition.git"
10
+ },
11
+ "publishConfig": {
12
+ "registry": "https://registry.npmjs.com/"
13
+ },
14
+ "files": [
15
+ "/lib",
16
+ "!/lib/**/*.js.map",
17
+ "/types"
18
+ ],
19
+ "main": "lib/index.js",
20
+ "types": "lib/index.d.ts",
21
+ "bin": {
22
+ "resource-definition": "lib/resource-definition/bin/index.js"
23
+ },
24
+ "scripts": {
25
+ "commit": "git-cz",
26
+ "clean:node_modules": "rimraf \"node_modules\"",
27
+ "clean:build": "rimraf \"lib\" \"test-js\"",
28
+ "clean:test": "rimraf \"coverage\"",
29
+ "clean": "npm run clean:build && npm run clean:test",
30
+ "build:ci": "tsc && tsc --project ./test && npm run lint",
31
+ "build": "npm run build:ci",
32
+ "lint": "eslint -c .eslintrc.json --ext .ts \"@(src|test)/**/*.ts?(x)\"",
33
+ "pretest": "npm run clean:test",
34
+ "next-version": "./node_modules/@aptos-scp/scp-component-commit-configs/next-version.sh",
35
+ "test:ci": "LOG_LEVEL=ALL JEST_JUNIT_OUTPUT_FILE=./reports/test-results.xml jest --silent --coverage --ci --reporters=default --reporters=jest-junit",
36
+ "test": "jest --coverage",
37
+ "publishPacts:ci": "node test-js/test-helpers/publish-pacts",
38
+ "watch": "tsc --watch",
39
+ "rb-post-patch": "./node_modules/@aptos-scp/scp-component-commit-configs/post-patch.sh",
40
+ "release": "npx semantic-release",
41
+ "prettier:format": "prettier --write ."
42
+ },
43
+ "dependencies": {
44
+ "dotenv": "^16.0.3"
45
+ },
46
+ "devDependencies": {
47
+ "@aptos-scp/eslint-config-scp": "^1.1.15",
48
+ "@aptos-scp/scp-component-commit-configs": "^5.0.9",
49
+ "@types/jest": "^29.5.14",
50
+ "eslint": "^8.35.0",
51
+ "jest": "^29.7.0",
52
+ "jest-junit": "^16.0.0",
53
+ "mocha": "^10.2.0",
54
+ "node-fetch": "^3.3.0",
55
+ "nyc": "^15.1.0",
56
+ "path": "^0.12.7",
57
+ "pjson": "^1.0.9",
58
+ "prettier": "^2.8.4",
59
+ "reflect-metadata": "^0.2.2",
60
+ "rimraf": "^6.0.1",
61
+ "source-map-support": "^0.5.21",
62
+ "ts-jest": "^29.3.4",
63
+ "ts-node": "^10.9.1",
64
+ "typescript": "^4.9.5"
65
+ },
66
+ "config": {
67
+ "pact_do_not_track": true,
68
+ "commitizen": {
69
+ "path": "./node_modules/cz-customizable"
70
+ },
71
+ "cz-customizable": {
72
+ "config": "./node_modules/@aptos-scp/scp-component-commit-configs/.cz-config.js"
73
+ }
74
+ },
75
+ "mocha": {
76
+ "require": [
77
+ "ts-node/register",
78
+ "source-map-support/register",
79
+ "reflect-metadata",
80
+ "./test-js/test/test-helpers/commonChaiSetup",
81
+ "./test-js/test/test-helpers/initializeLogging",
82
+ "./test-js/test/test-helpers/node-fetch-polyfill"
83
+ ],
84
+ "recursive": true,
85
+ "full-trace": true,
86
+ "spec": "test/**/*.spec.ts"
87
+ },
88
+ "nyc": {
89
+ "include": [
90
+ "src/**/*"
91
+ ],
92
+ "exclude": [
93
+ "**/test-helpers/**"
94
+ ],
95
+ "extension": [
96
+ ".ts"
97
+ ],
98
+ "reporter": [
99
+ "text-summary",
100
+ "html",
101
+ "lcov"
102
+ ],
103
+ "all": true,
104
+ "sourceMap": true,
105
+ "instrument": true,
106
+ "check-coverage": true,
107
+ "lines": 99,
108
+ "statements": 99,
109
+ "functions": 99,
110
+ "branches": 99
111
+ },
112
+ "husky": {
113
+ "hooks": {
114
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
115
+ }
116
+ },
117
+ "commitlint": {
118
+ "extends": [
119
+ "@aptos-scp/scp-component-commit-configs/.commitlintrc.js"
120
+ ]
121
+ }
122
+ }