@onivoro/onix 20.5.16 → 20.5.18

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/executors.json CHANGED
@@ -25,6 +25,11 @@
25
25
  "schema": "./src/executors/deploy-ecs/schema.json",
26
26
  "description": "deploy-ecs"
27
27
  },
28
+ "deploy-s3": {
29
+ "implementation": "./src/executors/deploy-s3/executor",
30
+ "schema": "./src/executors/deploy-s3/schema.json",
31
+ "description": "deploy-s3"
32
+ },
28
33
  "deploy-s3-react": {
29
34
  "implementation": "./src/executors/deploy-s3-react/executor",
30
35
  "schema": "./src/executors/deploy-s3-react/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onivoro/onix",
3
- "version": "20.5.16",
3
+ "version": "20.5.18",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -0,0 +1,3 @@
1
+ import { ExecutorSchema } from './schema';
2
+ declare const _default: import("@nx/devkit").PromiseExecutor<ExecutorSchema>;
3
+ export default _default;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const extract_project_build_outputs_function_1 = require("../../functions/extract-project-build-outputs.function");
5
+ const pmx_function_1 = require("../../functions/pmx.function");
6
+ const executor_factory_function_1 = require("../../functions/executor-factory.function");
7
+ const client_s3_1 = require("@aws-sdk/client-s3");
8
+ const resolve_aws_credentials_function_1 = require("../../functions/resolve-aws-credentials.function");
9
+ const upload_directory_to_s3_function_1 = require("../../functions/upload-directory-to-s3.function");
10
+ exports.default = (0, executor_factory_function_1.executorFactory)((options, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
11
+ const { region, bucket, omitAcl, prefix, profile } = options;
12
+ const [projectOutput] = (0, extract_project_build_outputs_function_1.extractProjectBuildOutputs)(context, context.projectName);
13
+ (0, pmx_function_1.pmxSpawn)(context, `nx build ${context.projectName}`);
14
+ const ACL = omitAcl ? undefined : 'public-read';
15
+ const s3Client = new client_s3_1.S3Client({ region, credentials: yield (0, resolve_aws_credentials_function_1.resolveAwsCredentials)(profile) });
16
+ yield (0, upload_directory_to_s3_function_1.uploadDirectoryToS3)({ directoryPath: projectOutput, bucketName: bucket, ACL }, s3Client);
17
+ }));
18
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../onix/src/executors/deploy-s3/executor.ts"],"names":[],"mappings":";;;AAEA,mHAAoG;AACpG,+DAAwD;AACxD,yFAA4E;AAC5E,kDAA8C;AAC9C,uGAAyF;AACzF,qGAAsF;AAEtF,kBAAe,IAAA,2CAAe,EAAC,CAC7B,OAAuB,EACvB,OAAwB,EACxB,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC7D,MAAM,CAAC,aAAa,CAAC,GAAG,IAAA,mEAA0B,EAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjF,IAAA,uBAAQ,EAAC,OAAO,EAAE,YAAY,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAErD,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC;IAEhD,MAAM,QAAQ,GAAG,IAAI,oBAAQ,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,IAAA,wDAAqB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAE7F,MAAM,IAAA,qDAAmB,EAAC,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;AACjG,CAAC,CAAA,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface ExecutorSchema {
2
+ bucket: string,
3
+ region: string,
4
+ prefix?: string,
5
+ omitAcl?: boolean,
6
+ profile?: string,
7
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "version": 2,
4
+ "title": "Deploy S3 executor",
5
+ "description": "",
6
+ "type": "object",
7
+ "properties": {
8
+ "bucket": {
9
+ "type": "string",
10
+ "description": "Name of the S3 bucket to use for uploading artifacts"
11
+ },
12
+ "profile": {
13
+ "type": "string",
14
+ "description": "AWS profile name (which must be defined in the ~/.aws/credentials file) if AWS keys aren't defined as env vars"
15
+ },
16
+ "region": {
17
+ "type": "string",
18
+ "description": "AWS region"
19
+ },
20
+ "prefix": {
21
+ "type": "string",
22
+ "description": "The prefix for S3 upload within the specified bucket"
23
+ },
24
+ "omitAcl": {
25
+ "type": "boolean",
26
+ "description": "Whether to use acl public-read for S3 push"
27
+ }
28
+ },
29
+ "required": [
30
+ "bucket",
31
+ "region"
32
+ ]
33
+ }
@@ -0,0 +1 @@
1
+ export declare function getContentType(filename: string): "text/plain" | "text/html" | "text/css" | "application/javascript" | "application/json" | "image/png" | "image/jpeg" | "application/pdf" | "application/octet-stream";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getContentType = getContentType;
4
+ const path_1 = require("path");
5
+ function getContentType(filename) {
6
+ const ext = (0, path_1.extname)(filename).toLowerCase();
7
+ switch (ext) {
8
+ case '.txt': return 'text/plain';
9
+ case '.html': return 'text/html';
10
+ case '.css': return 'text/css';
11
+ case '.js': return 'application/javascript';
12
+ case '.json': return 'application/json';
13
+ case '.png': return 'image/png';
14
+ case '.jpg':
15
+ case '.jpeg': return 'image/jpeg';
16
+ case '.pdf': return 'application/pdf';
17
+ default: return 'application/octet-stream';
18
+ }
19
+ }
20
+ //# sourceMappingURL=get-content-type.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-content-type.function.js","sourceRoot":"","sources":["../../../../onix/src/functions/get-content-type.function.ts"],"names":[],"mappings":";;AAEA,wCAcC;AAhBD,+BAA+B;AAE/B,SAAgB,cAAc,CAAC,QAAgB;IAC3C,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,QAAQ,GAAG,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,CAAC,OAAO,YAAY,CAAC;QACjC,KAAK,OAAO,CAAC,CAAC,OAAO,WAAW,CAAC;QACjC,KAAK,MAAM,CAAC,CAAC,OAAO,UAAU,CAAC;QAC/B,KAAK,KAAK,CAAC,CAAC,OAAO,wBAAwB,CAAC;QAC5C,KAAK,OAAO,CAAC,CAAC,OAAO,kBAAkB,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC;QAChC,KAAK,MAAM,CAAC;QACZ,KAAK,OAAO,CAAC,CAAC,OAAO,YAAY,CAAC;QAClC,KAAK,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC;QACtC,OAAO,CAAC,CAAC,OAAO,0BAA0B,CAAC;IAC/C,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { S3Client } from "@aws-sdk/client-s3";
2
+ export declare function uploadDirectoryToS3(_: {
3
+ directoryPath: string;
4
+ bucketName: string;
5
+ ACL: any;
6
+ prefix?: string;
7
+ }, s3Client: S3Client): Promise<void>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uploadDirectoryToS3 = uploadDirectoryToS3;
4
+ const tslib_1 = require("tslib");
5
+ const promises_1 = require("fs/promises");
6
+ const path_1 = require("path");
7
+ const get_content_type_function_1 = require("./get-content-type.function");
8
+ const client_s3_1 = require("@aws-sdk/client-s3");
9
+ function uploadDirectoryToS3(_, s3Client) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ const { directoryPath, bucketName, ACL, prefix } = _;
12
+ try {
13
+ const files = yield (0, promises_1.readdir)(directoryPath);
14
+ for (const file of files) {
15
+ const filePath = (0, path_1.join)(directoryPath, file);
16
+ const stats = yield (0, promises_1.stat)(filePath);
17
+ if (stats.isFile()) {
18
+ const fileContent = yield (0, promises_1.readFile)(filePath);
19
+ const params = {
20
+ Bucket: bucketName,
21
+ Key: `${prefix}${file}`,
22
+ Body: fileContent,
23
+ ContentType: (0, get_content_type_function_1.getContentType)(file),
24
+ ACL
25
+ };
26
+ yield s3Client.send(new client_s3_1.PutObjectCommand(params));
27
+ console.log(`Successfully uploaded ${file} to ${bucketName}`);
28
+ }
29
+ else if (stats.isDirectory()) {
30
+ yield uploadDirectoryToS3({ directoryPath: (0, path_1.resolve)(directoryPath, filePath), bucketName, ACL, prefix: `${filePath}/` }, s3Client);
31
+ }
32
+ }
33
+ console.log("All files uploaded successfully!");
34
+ }
35
+ catch (error) {
36
+ console.error("Error uploading files to S3:", error);
37
+ throw error;
38
+ }
39
+ });
40
+ }
41
+ //# sourceMappingURL=upload-directory-to-s3.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-directory-to-s3.function.js","sourceRoot":"","sources":["../../../../onix/src/functions/upload-directory-to-s3.function.ts"],"names":[],"mappings":";;AAKA,kDAgCC;;AArCD,0CAAsD;AACtD,+BAAqC;AACrC,2EAA6D;AAC7D,kDAAgE;AAEhE,SAAsB,mBAAmB,CAAC,CAA2E,EAAE,QAAkB;;QACrI,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACrD,IAAI,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,IAAA,kBAAO,EAAC,aAAa,CAAC,CAAC;YAE3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACvB,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,aAAa,EAAE,IAAI,CAAC,CAAC;gBAE3C,MAAM,KAAK,GAAG,MAAM,IAAA,eAAI,EAAC,QAAQ,CAAC,CAAC;gBACnC,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;oBACjB,MAAM,WAAW,GAAG,MAAM,IAAA,mBAAQ,EAAC,QAAQ,CAAC,CAAC;oBAE7C,MAAM,MAAM,GAAG;wBACX,MAAM,EAAE,UAAU;wBAClB,GAAG,EAAE,GAAG,MAAM,GAAG,IAAI,EAAE;wBACvB,IAAI,EAAE,WAAW;wBACjB,WAAW,EAAE,IAAA,0CAAc,EAAC,IAAI,CAAC;wBACjC,GAAG;qBACN,CAAC;oBAEF,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,4BAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;oBAClD,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,OAAO,UAAU,EAAE,CAAC,CAAC;gBAClE,CAAC;qBAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBAC7B,MAAM,mBAAmB,CAAC,EAAE,aAAa,EAAE,IAAA,cAAO,EAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;gBACtI,CAAC;YACL,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;CAAA"}
package/src/index.d.ts CHANGED
@@ -13,6 +13,10 @@ export * from './functions/load-env-file.function';
13
13
  export * from './functions/normalize-output-path.function';
14
14
  export * from './functions/pm.function';
15
15
  export * from './functions/pmx.function';
16
+ export * from './functions/resolve-aws-credentials.function';
17
+ export * from './functions/restart-ecs-service.function';
18
+ export * from './functions/to-cdn-path.function';
19
+ export * from './functions/upload-directory-to-s3.function';
16
20
  export * from './inference/add-docker-target.function';
17
21
  export * from './inference/add-docker-targets.function';
18
22
  export * from './inference/add-serve-target.function';
package/src/index.js CHANGED
@@ -16,6 +16,10 @@ tslib_1.__exportStar(require("./functions/load-env-file.function"), exports);
16
16
  tslib_1.__exportStar(require("./functions/normalize-output-path.function"), exports);
17
17
  tslib_1.__exportStar(require("./functions/pm.function"), exports);
18
18
  tslib_1.__exportStar(require("./functions/pmx.function"), exports);
19
+ tslib_1.__exportStar(require("./functions/resolve-aws-credentials.function"), exports);
20
+ tslib_1.__exportStar(require("./functions/restart-ecs-service.function"), exports);
21
+ tslib_1.__exportStar(require("./functions/to-cdn-path.function"), exports);
22
+ tslib_1.__exportStar(require("./functions/upload-directory-to-s3.function"), exports);
19
23
  tslib_1.__exportStar(require("./inference/add-docker-target.function"), exports);
20
24
  tslib_1.__exportStar(require("./inference/add-docker-targets.function"), exports);
21
25
  tslib_1.__exportStar(require("./inference/add-serve-target.function"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../onix/src/index.ts"],"names":[],"mappings":";;;AAAA,oEAA0C;AAC1C,wEAA8C;AAC9C,sEAA4C;AAE5C,mEAAyC;AAEzC,2DAAiC;AAEjC,6EAAmD;AACnD,gFAAsD;AACtD,6FAAmE;AACnE,6FAAmE;AACnE,6FAAmE;AACnE,sFAA4D;AAC5D,6EAAmD;AACnD,qFAA2D;AAC3D,kEAAwC;AACxC,mEAAyC;AAEzC,iFAAuD;AACvD,kFAAwD;AACxD,gFAAsD;AACtD,iFAAuD;AACvD,kFAAwD;AACxD,kFAAwD;AACxD,sFAA4D;AAE5D,uFAA6D;AAC7D,gFAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../onix/src/index.ts"],"names":[],"mappings":";;;AAAA,oEAA0C;AAC1C,wEAA8C;AAC9C,sEAA4C;AAE5C,mEAAyC;AAEzC,2DAAiC;AAEjC,6EAAmD;AACnD,gFAAsD;AACtD,6FAAmE;AACnE,6FAAmE;AACnE,6FAAmE;AACnE,sFAA4D;AAC5D,6EAAmD;AACnD,qFAA2D;AAC3D,kEAAwC;AACxC,mEAAyC;AACzC,uFAA6D;AAC7D,mFAAyD;AACzD,2EAAiD;AACjD,sFAA4D;AAE5D,iFAAuD;AACvD,kFAAwD;AACxD,gFAAsD;AACtD,iFAAuD;AACvD,kFAAwD;AACxD,kFAAwD;AACxD,sFAA4D;AAE5D,uFAA6D;AAC7D,gFAAsD"}