@onivoro/onix 20.5.35 → 20.5.37
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/package.json +1 -1
- package/src/executors/local/executor.js +5 -1
- package/src/executors/local/executor.js.map +1 -1
- package/src/executors/local/schema.d.ts +3 -0
- package/src/executors/local/schema.json +18 -0
- package/src/functions/copy-from-s3.function.d.ts +5 -0
- package/src/functions/copy-from-s3.function.js +55 -0
- package/src/functions/copy-from-s3.function.js.map +1 -0
- package/src/functions/push-image-to-ecr.function.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
package/package.json
CHANGED
|
@@ -4,8 +4,12 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const load_env_file_function_1 = require("../../functions/load-env-file.function");
|
|
5
5
|
const executor_factory_function_1 = require("../../functions/executor-factory.function");
|
|
6
6
|
const pmx_function_1 = require("../../functions/pmx.function");
|
|
7
|
+
const copy_from_s3_function_1 = require("../../functions/copy-from-s3.function");
|
|
7
8
|
exports.default = (0, executor_factory_function_1.executorFactory)((options, context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
-
const { debugPort, envFile } = options;
|
|
9
|
+
const { debugPort, envFile, copyFromS3 } = options;
|
|
10
|
+
if (copyFromS3) {
|
|
11
|
+
yield (0, copy_from_s3_function_1.copyFromS3)(copyFromS3);
|
|
12
|
+
}
|
|
9
13
|
(0, load_env_file_function_1.loadEnvFile)(envFile);
|
|
10
14
|
const inspectStatement = debugPort ? `--port=${debugPort}` : '';
|
|
11
15
|
(0, pmx_function_1.pmxSpawn)(context, `nx run ${context.projectName}:serve ${inspectStatement}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../onix/src/executors/local/executor.ts"],"names":[],"mappings":";;;AAIA,mFAAqE;AACrE,yFAA4E;AAC5E,+DAAwD;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../onix/src/executors/local/executor.ts"],"names":[],"mappings":";;;AAIA,mFAAqE;AACrE,yFAA4E;AAC5E,+DAAwD;AACxD,iFAA2E;AAE3E,kBAAe,IAAA,2CAAe,EAAC,CAC7B,OAAuB,EACvB,OAAwB,EACxB,EAAE;IACF,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IAEnD,IAAG,UAAU,EAAE,CAAC;QACd,MAAM,IAAA,kCAAI,EAAC,UAAU,CAAC,CAAC;IACzB,CAAC;IAED,IAAA,oCAAW,EAAC,OAAO,CAAC,CAAC;IAErB,MAAM,gBAAgB,GAAG,SAAS,CAAC,CAAC,CAAC,UAAU,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAEhE,IAAA,uBAAQ,EAAC,OAAO,EAAE,UAAU,OAAO,CAAC,WAAW,UAAU,gBAAgB,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAA,CAAC,CAAC"}
|
|
@@ -12,6 +12,24 @@
|
|
|
12
12
|
"envFile": {
|
|
13
13
|
"type": "string",
|
|
14
14
|
"description": "Path and name of the .env file to load"
|
|
15
|
+
},
|
|
16
|
+
"copyFromS3": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"description": "Configuration for copying files from S3",
|
|
19
|
+
"properties": {
|
|
20
|
+
"profile": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "AWS profile to use"
|
|
23
|
+
},
|
|
24
|
+
"files": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"description": "Object mapping S3 keys to local file paths",
|
|
27
|
+
"additionalProperties": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["profile", "files"]
|
|
15
33
|
}
|
|
16
34
|
},
|
|
17
35
|
"required": []
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.copyFromS3 = copyFromS3;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
6
|
+
const os_1 = require("os");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const promises_1 = require("stream/promises");
|
|
10
|
+
const resolve_aws_credentials_function_1 = require("./resolve-aws-credentials.function");
|
|
11
|
+
function copyFromS3(config) {
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const s3Client = new client_s3_1.S3Client({ credentials: yield (0, resolve_aws_credentials_function_1.resolveAwsCredentials)(config.profile) });
|
|
14
|
+
const promises = Object.entries(config.files).map((_a) => tslib_1.__awaiter(this, [_a], void 0, function* ([s3Path, localPath]) {
|
|
15
|
+
try {
|
|
16
|
+
// Normalize S3 path - remove s3:// prefix if present and split bucket/key
|
|
17
|
+
const cleanS3Path = s3Path.replace(/^s3:\/\//, '');
|
|
18
|
+
const [bucket, ...keyParts] = cleanS3Path.split('/');
|
|
19
|
+
const key = keyParts.join('/');
|
|
20
|
+
if (!bucket || !key) {
|
|
21
|
+
throw new Error(`Invalid S3 path: ${s3Path}. Expected format: s3://bucket/key or bucket/key`);
|
|
22
|
+
}
|
|
23
|
+
// Resolve local path - replace ~ with home directory
|
|
24
|
+
const resolvedLocalPath = localPath.startsWith('~')
|
|
25
|
+
? localPath.replace('~', (0, os_1.homedir)())
|
|
26
|
+
: localPath;
|
|
27
|
+
// Ensure the local directory exists
|
|
28
|
+
const localDir = (0, path_1.dirname)(resolvedLocalPath);
|
|
29
|
+
if (!(0, fs_1.existsSync)(localDir)) {
|
|
30
|
+
(0, fs_1.mkdirSync)(localDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
// Get object from S3
|
|
33
|
+
console.log(`Copying s3://${bucket}/${key} to ${resolvedLocalPath}...`);
|
|
34
|
+
const getObjectCommand = new client_s3_1.GetObjectCommand({
|
|
35
|
+
Bucket: bucket,
|
|
36
|
+
Key: key,
|
|
37
|
+
});
|
|
38
|
+
const response = yield s3Client.send(getObjectCommand);
|
|
39
|
+
if (!response.Body) {
|
|
40
|
+
throw new Error(`No body in S3 response for ${s3Path}`);
|
|
41
|
+
}
|
|
42
|
+
// Stream the file to local disk
|
|
43
|
+
const writeStream = (0, fs_1.createWriteStream)(resolvedLocalPath);
|
|
44
|
+
yield (0, promises_1.pipeline)(response.Body, writeStream);
|
|
45
|
+
console.log(`✓ Successfully copied s3://${bucket}/${key} to ${resolvedLocalPath}`);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error(`✗ Failed to copy ${s3Path} to ${localPath}:`, error);
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
return yield Promise.all(promises);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=copy-from-s3.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy-from-s3.function.js","sourceRoot":"","sources":["../../../../onix/src/functions/copy-from-s3.function.ts"],"names":[],"mappings":";;AAYA,gCAoDC;;AAhED,kDAAgE;AAChE,2BAA6B;AAC7B,+BAA+B;AAC/B,2BAA8D;AAC9D,8CAA2C;AAC3C,yFAA2E;AAO3E,SAAsB,UAAU,CAAC,MAAyB;;QACxD,MAAM,QAAQ,GAAG,IAAI,oBAAQ,CAAC,EAAE,WAAW,EAAE,MAAM,IAAA,wDAAqB,EAAC,MAAM,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC;QAE3F,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAA4B,EAAE,kDAAvB,CAAC,MAAM,EAAE,SAAS,CAAC;YAC1E,IAAI,CAAC;gBACH,0EAA0E;gBAC1E,MAAM,WAAW,GAAG,MAAM,CAAC,O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AAW,GAAG,IAAA,sBAAiB,EAAC,iBAAiB,CAAC,CAAC;gBACzD,MAAM,IAAA,mBAAQ,EAAC,QAAQ,CAAC,IAA6B,EAAE,WAAW,CAAC,CAAC;gBAEpE,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,IAAI,GAAG,OAAO,iBAAiB,EAAE,CAAC,CAAC;YAErF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,oBAAoB,MAAM,OAAO,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC;gBACpE,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;QAEH,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push-image-to-ecr.function.js","sourceRoot":"","sources":["../../../../onix/src/functions/push-image-to-ecr.function.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"push-image-to-ecr.function.js","sourceRoot":"","sources":["../../../../onix/src/functions/push-image-to-ecr.function.ts"],"names":[],"mappings":";;AAYA,wCAsEC;;AAlFD,oDAA+F;AAC/F,uCAAoC;AACpC,iDAAyC;AACzC,yFAA2E;AAS3E,SAAsB,cAAc;iEAAC,EACnC,MAAM,EACN,GAAG,EACH,UAAU,EACV,OAAO,EACS;;QAChB,IAAI,CAAC;YACH,MAAM,MAAM,GAAoB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,IAAA,wDAAqB,EAAC,OAAO,CAAC,EAAE,CAAC;YAC9F,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,MAAM,CAAC,CAAC;YAExC,MAAM,WAAW,GAAG,IAAI,yCAA4B,CAAC;gBACnD,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;aACnD,CAAC,CAAC;YAEH,MAAM,YAA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CAAC;YAED,MAAM,WAAW,GAAG,eAAe,GAAG,EAAE,CAAC;YACzC,IAAI,CAAC;gBACH,IAAA,wBAAQ,EAAC,WAAW,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAC9C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,eAAM,CAAC,KAAK,CAAC,+BAA+B,WAAW,EAAE,CAAC,CAAC;gBAC3D,MAAM,KAAK,CAAC;YACd,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC5C,eAAM,CAAC,KAAK,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,CAAC;YAE7B,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CAAA"}
|
package/src/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './types/onix-config.type';
|
|
|
5
5
|
export * from './plugins/plugin';
|
|
6
6
|
export * from './functions/object-to-env-exports.function';
|
|
7
7
|
export * from './functions/as-s3-app-key.function';
|
|
8
|
+
export * from './functions/copy-from-s3.function';
|
|
8
9
|
export * from './functions/executor-factory.function';
|
|
9
10
|
export * from './functions/extract-project-build-outputs.function';
|
|
10
11
|
export * from './functions/extract-project-configuration.function';
|
package/src/index.js
CHANGED
|
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./types/onix-config.type"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./plugins/plugin"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./functions/object-to-env-exports.function"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./functions/as-s3-app-key.function"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./functions/copy-from-s3.function"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./functions/executor-factory.function"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./functions/extract-project-build-outputs.function"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./functions/extract-project-configuration.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,qFAA2D;AAC3D,6EAAmD;AACnD,gFAAsD;AACtD,6FAAmE;AACnE,6FAAmE;AACnE,6FAAmE;AACnE,sFAA4D;AAC5D,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"}
|
|
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,qFAA2D;AAC3D,6EAAmD;AACnD,4EAAkD;AAClD,gFAAsD;AACtD,6FAAmE;AACnE,6FAAmE;AACnE,6FAAmE;AACnE,sFAA4D;AAC5D,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"}
|