@onivoro/onix 20.5.22 → 20.5.23

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
@@ -35,6 +35,11 @@
35
35
  "schema": "./src/executors/deploy-s3-react/schema.json",
36
36
  "description": "deploy-s3-react"
37
37
  },
38
+ "deploy-s3-sync": {
39
+ "implementation": "./src/executors/deploy-s3-sync/executor",
40
+ "schema": "./src/executors/deploy-s3-sync/schema.json",
41
+ "description": "deploy-s3-sync"
42
+ },
38
43
  "deploy-s3-vite": {
39
44
  "implementation": "./src/executors/deploy-s3-vite/executor",
40
45
  "schema": "./src/executors/deploy-s3-vite/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onivoro/onix",
3
- "version": "20.5.22",
3
+ "version": "20.5.23",
4
4
  "type": "commonjs",
5
5
  "main": "./src/index.js",
6
6
  "typings": "./src/index.d.ts",
@@ -40,7 +40,7 @@ exports.default = (0, executor_factory_function_1.executorFactory)((options, con
40
40
  const ACL = omitAcl ? undefined : 'public-read';
41
41
  const s3Client = new client_s3_1.S3Client({ region, credentials: yield (0, resolve_aws_credentials_function_1.resolveAwsCredentials)(profile) });
42
42
  yield Promise.all(fileMappings.map((_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ contentType, original, key }) {
43
- yield new Promise(resolve => setTimeout(resolve, 2000));
43
+ yield new Promise(resolve => setTimeout(resolve, 4000));
44
44
  yield s3Client.send(new client_s3_1.PutObjectCommand({
45
45
  Bucket: bucket,
46
46
  ContentType: contentType,
@@ -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,22 @@
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 path_1 = require("path");
8
+ const client_s3_1 = require("@aws-sdk/client-s3");
9
+ const resolve_aws_credentials_function_1 = require("../../functions/resolve-aws-credentials.function");
10
+ const s3_sync_directory_function_1 = require("../../functions/s3-sync-directory.function");
11
+ const assetsFolder = 'assets';
12
+ exports.default = (0, executor_factory_function_1.executorFactory)((options, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
13
+ const { region, bucket, omitAcl, profile, localDirectory } = options;
14
+ const [projectOutput] = (0, extract_project_build_outputs_function_1.extractProjectBuildOutputs)(context, context.projectName);
15
+ const app = context.projectName;
16
+ (0, pmx_function_1.pmxSpawn)(context, `nx build ${app}`);
17
+ const resolvedLocalDirectory = (0, path_1.resolve)(projectOutput, localDirectory);
18
+ const ACL = omitAcl ? undefined : 'public-read';
19
+ const s3Client = new client_s3_1.S3Client({ region, credentials: yield (0, resolve_aws_credentials_function_1.resolveAwsCredentials)(profile) });
20
+ yield (0, s3_sync_directory_function_1.s3SyncDirectory)({ s3Client, bucket, localDirectory: resolvedLocalDirectory, ACL });
21
+ }));
22
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../onix/src/executors/deploy-s3-sync/executor.ts"],"names":[],"mappings":";;;AAEA,mHAAoG;AACpG,+DAAwD;AACxD,yFAA4E;AAC5E,+BAA+B;AAC/B,kDAA8C;AAC9C,uGAAyF;AACzF,2FAA6E;AAE7E,MAAM,YAAY,GAAG,QAAQ,CAAA;AAE7B,kBAAe,IAAA,2CAAe,EAAC,CAC7B,OAAuB,EACvB,OAAwB,EACxB,EAAE;IACF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IACrE,MAAM,CAAC,aAAa,CAAC,GAAG,IAAA,mEAA0B,EAAC,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAEjF,MAAM,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;IAEhC,IAAA,uBAAQ,EAAC,OAAO,EAAE,YAAY,GAAG,EAAE,CAAC,CAAC;IAErC,MAAM,sBAAsB,GAAG,IAAA,cAAO,EAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAEtE,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,4CAAe,EAAC,EAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1F,CAAC,CAAA,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface ExecutorSchema {
2
+ bucket: string,
3
+ region: string,
4
+ omitAcl?: boolean,
5
+ profile?: string,
6
+ localDirectory: string,
7
+ }
@@ -0,0 +1,34 @@
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
+ "omitAcl": {
21
+ "type": "boolean",
22
+ "description": "Whether to use acl public-read for S3 push"
23
+ },
24
+ "localDirectory": {
25
+ "type": "string",
26
+ "description": "Local directory to upload to S3"
27
+ }
28
+ },
29
+ "required": [
30
+ "bucket",
31
+ "localDirectory",
32
+ "region"
33
+ ]
34
+ }
@@ -0,0 +1,8 @@
1
+ import { ObjectCannedACL, S3Client } from '@aws-sdk/client-s3';
2
+ export declare function s3SyncDirectory({ s3Client, bucket, localDirectory, s3Prefix, ACL }: {
3
+ s3Client: S3Client;
4
+ bucket: string;
5
+ localDirectory: string;
6
+ s3Prefix?: string;
7
+ ACL?: ObjectCannedACL;
8
+ }): Promise<void>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.s3SyncDirectory = s3SyncDirectory;
4
+ const tslib_1 = require("tslib");
5
+ const client_s3_1 = require("@aws-sdk/client-s3");
6
+ const devkit_1 = require("@nx/devkit");
7
+ const promises_1 = require("fs/promises");
8
+ const path_1 = require("path");
9
+ function s3SyncDirectory(_a) {
10
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ s3Client, bucket, localDirectory, s3Prefix = '', ACL }) {
11
+ function walk(dir) {
12
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
+ const entries = yield (0, promises_1.readdir)(dir, { withFileTypes: true });
14
+ const files = yield Promise.all(entries.map((entry) => tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ const res = (0, path_1.join)(dir, entry.name);
16
+ return entry.isDirectory() ? yield walk(res) : res;
17
+ })));
18
+ return files.flat();
19
+ });
20
+ }
21
+ const files = yield walk(localDirectory);
22
+ for (const filePath of files) {
23
+ const fileContent = yield (0, promises_1.readFile)(filePath);
24
+ const key = path_1.posix.join(s3Prefix, (0, path_1.relative)(localDirectory, filePath).split('\\').join('/'));
25
+ yield s3Client.send(new client_s3_1.PutObjectCommand({
26
+ Bucket: bucket,
27
+ Key: key,
28
+ Body: fileContent,
29
+ ACL
30
+ }));
31
+ devkit_1.logger.info(`Uploaded ${filePath} to s3://${bucket}/${key}`);
32
+ }
33
+ });
34
+ }
35
+ //# sourceMappingURL=s3-sync-directory.function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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MAAM;gBACd,GAAG,EAAE,GAAG;gBACR,IAAI,EAAE,WAAW;gBACjB,GAAG;aACJ,CAAC,CAAC,CAAC;YAEJ,eAAM,CAAC,IAAI,CAAC,YAAY,QAAQ,YAAY,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CAAA"}
package/src/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export * from './functions/pm.function';
15
15
  export * from './functions/pmx.function';
16
16
  export * from './functions/resolve-aws-credentials.function';
17
17
  export * from './functions/restart-ecs-service.function';
18
+ export * from './functions/s3-sync-directory.function';
18
19
  export * from './functions/to-cdn-path.function';
19
20
  export * from './functions/upload-directory-to-s3.function';
20
21
  export * from './inference/add-docker-target.function';
package/src/index.js CHANGED
@@ -18,6 +18,7 @@ tslib_1.__exportStar(require("./functions/pm.function"), exports);
18
18
  tslib_1.__exportStar(require("./functions/pmx.function"), exports);
19
19
  tslib_1.__exportStar(require("./functions/resolve-aws-credentials.function"), exports);
20
20
  tslib_1.__exportStar(require("./functions/restart-ecs-service.function"), exports);
21
+ tslib_1.__exportStar(require("./functions/s3-sync-directory.function"), exports);
21
22
  tslib_1.__exportStar(require("./functions/to-cdn-path.function"), exports);
22
23
  tslib_1.__exportStar(require("./functions/upload-directory-to-s3.function"), exports);
23
24
  tslib_1.__exportStar(require("./inference/add-docker-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;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"}
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,iFAAuD;AACvD,2EAAiD;AACjD,sFAA4D;AAE5D,iFAAuD;AACvD,kFAAwD;AACxD,gFAAsD;AACtD,iFAAuD;AACvD,kFAAwD;AACxD,kFAAwD;AACxD,sFAA4D;AAE5D,uFAA6D;AAC7D,gFAAsD"}