@nizza/devkit 0.1.0-beta.0 → 0.1.0-beta.1

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.
@@ -20,7 +20,21 @@ async function createCloudFrontInvalidation(distributionId, invalidationPaths) {
20
20
  await utils.runCommand(command);
21
21
  devkit.logger.info('🔄 CloudFront invalidation created.');
22
22
  }
23
+ function validateCustomPath(args) {
24
+ devkit.logger.info(`🔃 Using S3 custom path: "${args.customPath}"`);
25
+ let s3BucketPath = args.s3BucketPath;
26
+ let cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths;
27
+ if (args.customPath) {
28
+ s3BucketPath = args.s3BucketPath.replace('{customPath}', args.customPath);
29
+ cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths.map((x)=>x.replace('{customPath}', args.customPath));
30
+ }
31
+ return {
32
+ s3BucketPath,
33
+ cloudFrontInvalidationPaths
34
+ };
35
+ }
23
36
 
24
37
  exports.cleanS3Bucket = cleanS3Bucket;
25
38
  exports.copyAssetsToS3 = copyAssetsToS3;
26
39
  exports.createCloudFrontInvalidation = createCloudFrontInvalidation;
40
+ exports.validateCustomPath = validateCustomPath;
@@ -6,8 +6,9 @@ var helpers = require('./helpers.cjs');
6
6
  async function deployExecutor(opts, ctx) {
7
7
  try {
8
8
  const { root, name } = utils.getProjectConfig(ctx);
9
- const { s3BucketPath, cloudFrontDistributionId, cloudFrontInvalidationPaths, skipBuild = false } = opts;
9
+ const { cloudFrontDistributionId, skipBuild = false } = opts;
10
10
  const buildTarget = `${name}:${opts.buildTarget}`;
11
+ const { s3BucketPath, cloudFrontInvalidationPaths } = helpers.validateCustomPath(opts);
11
12
  if (!skipBuild) await utils.runCommand(`nx run ${buildTarget}`);
12
13
  await helpers.cleanS3Bucket(s3BucketPath);
13
14
  await helpers.copyAssetsToS3(s3BucketPath, root);
@@ -9,6 +9,10 @@
9
9
  "type": "string",
10
10
  "description": "S3 BUCKET ROUTE"
11
11
  },
12
+ "customPath": {
13
+ "type": "string",
14
+ "description": "Optional path to deploy to a custom s3BucketPath folder: Ie: pmx run ssv-script:deploy:custom --buildTarget build:prod --customPath jose"
15
+ },
12
16
  "cloudFrontDistributionId": {
13
17
  "type": "string",
14
18
  "description": "Cloudfront distribution id for cache invalidation"
@@ -18,5 +18,18 @@ async function createCloudFrontInvalidation(distributionId, invalidationPaths) {
18
18
  await runCommand(command);
19
19
  logger.info('🔄 CloudFront invalidation created.');
20
20
  }
21
+ function validateCustomPath(args) {
22
+ logger.info(`🔃 Using S3 custom path: "${args.customPath}"`);
23
+ let s3BucketPath = args.s3BucketPath;
24
+ let cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths;
25
+ if (args.customPath) {
26
+ s3BucketPath = args.s3BucketPath.replace('{customPath}', args.customPath);
27
+ cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths.map((x)=>x.replace('{customPath}', args.customPath));
28
+ }
29
+ return {
30
+ s3BucketPath,
31
+ cloudFrontInvalidationPaths
32
+ };
33
+ }
21
34
 
22
- export { cleanS3Bucket, copyAssetsToS3, createCloudFrontInvalidation };
35
+ export { cleanS3Bucket, copyAssetsToS3, createCloudFrontInvalidation, validateCustomPath };
@@ -1,11 +1,12 @@
1
1
  import { getProjectConfig, runCommand, ok, err } from '../shared/utils.mjs';
2
- import { cleanS3Bucket, copyAssetsToS3, createCloudFrontInvalidation } from './helpers.mjs';
2
+ import { validateCustomPath, cleanS3Bucket, copyAssetsToS3, createCloudFrontInvalidation } from './helpers.mjs';
3
3
 
4
4
  async function deployExecutor(opts, ctx) {
5
5
  try {
6
6
  const { root, name } = getProjectConfig(ctx);
7
- const { s3BucketPath, cloudFrontDistributionId, cloudFrontInvalidationPaths, skipBuild = false } = opts;
7
+ const { cloudFrontDistributionId, skipBuild = false } = opts;
8
8
  const buildTarget = `${name}:${opts.buildTarget}`;
9
+ const { s3BucketPath, cloudFrontInvalidationPaths } = validateCustomPath(opts);
9
10
  if (!skipBuild) await runCommand(`nx run ${buildTarget}`);
10
11
  await cleanS3Bucket(s3BucketPath);
11
12
  await copyAssetsToS3(s3BucketPath, root);
@@ -9,6 +9,10 @@
9
9
  "type": "string",
10
10
  "description": "S3 BUCKET ROUTE"
11
11
  },
12
+ "customPath": {
13
+ "type": "string",
14
+ "description": "Optional path to deploy to a custom s3BucketPath folder: Ie: pmx run ssv-script:deploy:custom --buildTarget build:prod --customPath jose"
15
+ },
12
16
  "cloudFrontDistributionId": {
13
17
  "type": "string",
14
18
  "description": "Cloudfront distribution id for cache invalidation"
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface ExecutorOptions {
12
12
  cloudFrontDistributionId: string;
13
13
  cloudFrontInvalidationPaths: string[];
14
14
  buildTarget: string;
15
+ customPath?: string;
15
16
  skipBuild?: boolean;
16
17
  }
17
18
  export function deployExecutor(opts: ExecutorOptions, ctx: ExecutorContext): Promise<ExecutorResponse>;
@@ -62,7 +63,8 @@ export declare enum Flag {
62
63
  SOURCEMAP = "source-maps",
63
64
  ANALYZE = "analyze",
64
65
  VERBOSE = "verbose",
65
- VERBOSE_ALIAS = "v"
66
+ VERBOSE_ALIAS = "v",
67
+ HTTPS = "https"
66
68
  }
67
69
  export declare enum Target {
68
70
  BUILD = "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nizza/devkit",
3
- "version": "0.1.0-beta.0",
3
+ "version": "0.1.0-beta.1",
4
4
  "type": "module",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.mjs",