@nizza/devkit 0.1.0-beta.0 → 0.1.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.
Files changed (19) hide show
  1. package/dist/cjs/executors/deploy/helpers.cjs +14 -0
  2. package/dist/cjs/executors/deploy/index.cjs +2 -1
  3. package/dist/cjs/executors/deploy/schema.json +4 -0
  4. package/dist/cjs/index.cjs +5 -5
  5. package/dist/cjs/node_modules/.pnpm/{@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4 → @vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12}/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.cjs +5 -3
  6. package/dist/cjs/node_modules/.pnpm/{@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4 → @vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12}/node_modules/@vitejs/plugin-basic-ssl/dist/index.cjs +10 -6
  7. package/dist/cjs/scripts/changeset-pre-mode.cjs +1 -1
  8. package/dist/cjs/vitejs/config-builder/plugins.cjs +1 -1
  9. package/dist/cjs/vitejs/config-builder/shared/utils/viteCommand.cjs +1 -1
  10. package/dist/esm/executors/deploy/helpers.mjs +14 -1
  11. package/dist/esm/executors/deploy/index.mjs +3 -2
  12. package/dist/esm/executors/deploy/schema.json +4 -0
  13. package/dist/esm/node_modules/.pnpm/{@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4 → @vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12}/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.mjs +5 -3
  14. package/dist/esm/node_modules/.pnpm/{@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4 → @vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12}/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs +10 -6
  15. package/dist/esm/scripts/changeset-pre-mode.mjs +1 -1
  16. package/dist/esm/vitejs/config-builder/plugins.mjs +1 -1
  17. package/dist/esm/vitejs/config-builder/shared/utils/viteCommand.mjs +1 -1
  18. package/dist/index.d.ts +3 -1
  19. package/package.json +1 -1
@@ -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
+ let s3BucketPath = args.s3BucketPath;
25
+ let cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths;
26
+ if (args.customPath) {
27
+ devkit.logger.info(`🔃 Using S3 custom path: "${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"
@@ -21,23 +21,23 @@ exports.publishExecutor = index$2;
21
21
  exports.updateExecutorsFileExecutor = index$3;
22
22
  exports.vtexLinkExecutor = index$4;
23
23
  exports.createConfigBuilder = main.createConfigBuilder;
24
- Object.defineProperty(exports, 'Flag', {
24
+ Object.defineProperty(exports, "Flag", {
25
25
  enumerable: true,
26
26
  get: function () { return types.Flag; }
27
27
  });
28
- Object.defineProperty(exports, 'ProjectType', {
28
+ Object.defineProperty(exports, "ProjectType", {
29
29
  enumerable: true,
30
30
  get: function () { return types.ProjectType; }
31
31
  });
32
- Object.defineProperty(exports, 'Stage', {
32
+ Object.defineProperty(exports, "Stage", {
33
33
  enumerable: true,
34
34
  get: function () { return types.Stage; }
35
35
  });
36
- Object.defineProperty(exports, 'Target', {
36
+ Object.defineProperty(exports, "Target", {
37
37
  enumerable: true,
38
38
  get: function () { return types.Target; }
39
39
  });
40
- Object.defineProperty(exports, 'ViteMode', {
40
+ Object.defineProperty(exports, "ViteMode", {
41
41
  enumerable: true,
42
42
  get: function () { return types.ViteMode; }
43
43
  });
@@ -19479,9 +19479,10 @@ function toPositiveHex(hexString) {
19479
19479
  mostSignificativeHexAsInt -= 8;
19480
19480
  return mostSignificativeHexAsInt.toString() + hexString.substring(1);
19481
19481
  }
19482
- function createCertificate() {
19482
+ function createCertificate(name = "example.org", domains) {
19483
19483
  const days = 30;
19484
19484
  const keySize = 2048;
19485
+ const appendDomains = domains ? domains.map((item) => ({ type: 2, value: item })) : [];
19485
19486
  const extensions = [
19486
19487
  {
19487
19488
  name: "keyUsage",
@@ -19528,14 +19529,15 @@ function createCertificate() {
19528
19529
  {
19529
19530
  type: 7,
19530
19531
  ip: "fe80::1"
19531
- }
19532
+ },
19533
+ ...appendDomains
19532
19534
  ]
19533
19535
  }
19534
19536
  ];
19535
19537
  const attrs = [
19536
19538
  {
19537
19539
  name: "commonName",
19538
- value: "example.org"
19540
+ value: name
19539
19541
  },
19540
19542
  {
19541
19543
  name: "countryName",
@@ -6,18 +6,22 @@ var path = require('node:path');
6
6
  var node_fs = require('node:fs');
7
7
 
8
8
  const defaultCacheDir = "node_modules/.vite";
9
- function viteBasicSslPlugin() {
9
+ function viteBasicSslPlugin(options) {
10
10
  return {
11
11
  name: "vite:basic-ssl",
12
12
  async configResolved(config) {
13
- const certificate = await getCertificate((config.cacheDir ?? defaultCacheDir) + "/basic-ssl");
13
+ const certificate = await getCertificate(options?.certDir ?? (config.cacheDir ?? defaultCacheDir) + "/basic-ssl", options?.name, options?.domains);
14
14
  const https = () => ({ cert: certificate, key: certificate });
15
- config.server.https = Object.assign({}, config.server.https, https());
16
- config.preview.https = Object.assign({}, config.preview.https, https());
15
+ if (config.server.https === void 0 || !!config.server.https) {
16
+ config.server.https = Object.assign({}, config.server.https, https());
17
+ }
18
+ if (config.preview.https === void 0 || !!config.preview.https) {
19
+ config.preview.https = Object.assign({}, config.preview.https, https());
20
+ }
17
21
  }
18
22
  };
19
23
  }
20
- async function getCertificate(cacheDir) {
24
+ async function getCertificate(cacheDir, name, domains) {
21
25
  const cachePath = path.join(cacheDir, "_cert.pem");
22
26
  try {
23
27
  const [stat, content] = await Promise.all([
@@ -29,7 +33,7 @@ async function getCertificate(cacheDir) {
29
33
  }
30
34
  return content;
31
35
  } catch {
32
- const content = (await Promise.resolve().then(function () { return require('./chunks/certificate.cjs'); })).createCertificate();
36
+ const content = (await Promise.resolve().then(function () { return require('./chunks/certificate.cjs'); })).createCertificate(name, domains);
33
37
  node_fs.promises.mkdir(cacheDir, { recursive: true }).then(() => node_fs.promises.writeFile(cachePath, content)).catch(() => {
34
38
  });
35
39
  return content;
@@ -2,7 +2,7 @@
2
2
 
3
3
  var devkit = require('@nx/devkit');
4
4
  var child_process = require('child_process');
5
- var promises = require('fs/promises');
5
+ var promises = require('node:fs/promises');
6
6
  var path = require('path');
7
7
  var util = require('util');
8
8
 
@@ -19,7 +19,7 @@ require('crypto');
19
19
  require('fs');
20
20
  require('chalk');
21
21
  require('mri');
22
- var index$1 = require('../../node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.cjs');
22
+ var index$1 = require('../../node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12/node_modules/@vitejs/plugin-basic-ssl/dist/index.cjs');
23
23
 
24
24
  /**
25
25
  * Base plugins configuration for apps and libs.
@@ -18,7 +18,7 @@ var types = require('../types.cjs');
18
18
  const nxEnv = vite.loadEnv(mode, process.cwd(), 'NX');
19
19
  const nxCommandString = process?.env?.['npm_package_scripts_nx'];
20
20
  const modeIsProd = mode === types.ViteMode.PROD;
21
- const stage = (nxEnv?.['NX_TASK_TARGET_CONFIGURATION']) ?? (modeIsProd ? types.Stage.PROD : types.Stage.DEV);
21
+ const stage = nxEnv?.['NX_TASK_TARGET_CONFIGURATION'] ?? (modeIsProd ? types.Stage.PROD : types.Stage.DEV);
22
22
  const target = nxEnv?.['NX_TASK_TARGET_TARGET'] ?? types.Target.BUILD;
23
23
  const flags = getViteCmdFlags(nxCommandString);
24
24
  const showIn = {
@@ -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
+ let s3BucketPath = args.s3BucketPath;
23
+ let cloudFrontInvalidationPaths = args.cloudFrontInvalidationPaths;
24
+ if (args.customPath) {
25
+ logger.info(`🔃 Using S3 custom path: "${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"
@@ -19477,9 +19477,10 @@ function toPositiveHex(hexString) {
19477
19477
  mostSignificativeHexAsInt -= 8;
19478
19478
  return mostSignificativeHexAsInt.toString() + hexString.substring(1);
19479
19479
  }
19480
- function createCertificate() {
19480
+ function createCertificate(name = "example.org", domains) {
19481
19481
  const days = 30;
19482
19482
  const keySize = 2048;
19483
+ const appendDomains = domains ? domains.map((item) => ({ type: 2, value: item })) : [];
19483
19484
  const extensions = [
19484
19485
  {
19485
19486
  name: "keyUsage",
@@ -19526,14 +19527,15 @@ function createCertificate() {
19526
19527
  {
19527
19528
  type: 7,
19528
19529
  ip: "fe80::1"
19529
- }
19530
+ },
19531
+ ...appendDomains
19530
19532
  ]
19531
19533
  }
19532
19534
  ];
19533
19535
  const attrs = [
19534
19536
  {
19535
19537
  name: "commonName",
19536
- value: "example.org"
19538
+ value: name
19537
19539
  },
19538
19540
  {
19539
19541
  name: "countryName",
@@ -2,18 +2,22 @@ import path from 'node:path';
2
2
  import { promises } from 'node:fs';
3
3
 
4
4
  const defaultCacheDir = "node_modules/.vite";
5
- function viteBasicSslPlugin() {
5
+ function viteBasicSslPlugin(options) {
6
6
  return {
7
7
  name: "vite:basic-ssl",
8
8
  async configResolved(config) {
9
- const certificate = await getCertificate((config.cacheDir ?? defaultCacheDir) + "/basic-ssl");
9
+ const certificate = await getCertificate(options?.certDir ?? (config.cacheDir ?? defaultCacheDir) + "/basic-ssl", options?.name, options?.domains);
10
10
  const https = () => ({ cert: certificate, key: certificate });
11
- config.server.https = Object.assign({}, config.server.https, https());
12
- config.preview.https = Object.assign({}, config.preview.https, https());
11
+ if (config.server.https === void 0 || !!config.server.https) {
12
+ config.server.https = Object.assign({}, config.server.https, https());
13
+ }
14
+ if (config.preview.https === void 0 || !!config.preview.https) {
15
+ config.preview.https = Object.assign({}, config.preview.https, https());
16
+ }
13
17
  }
14
18
  };
15
19
  }
16
- async function getCertificate(cacheDir) {
20
+ async function getCertificate(cacheDir, name, domains) {
17
21
  const cachePath = path.join(cacheDir, "_cert.pem");
18
22
  try {
19
23
  const [stat, content] = await Promise.all([
@@ -25,7 +29,7 @@ async function getCertificate(cacheDir) {
25
29
  }
26
30
  return content;
27
31
  } catch {
28
- const content = (await import('./chunks/certificate.mjs')).createCertificate();
32
+ const content = (await import('./chunks/certificate.mjs')).createCertificate(name, domains);
29
33
  promises.mkdir(cacheDir, { recursive: true }).then(() => promises.writeFile(cachePath, content)).catch(() => {
30
34
  });
31
35
  return content;
@@ -1,6 +1,6 @@
1
1
  import { logger } from '@nx/devkit';
2
2
  import { exec } from 'child_process';
3
- import { readFile } from 'fs/promises';
3
+ import { readFile } from 'node:fs/promises';
4
4
  import { resolve } from 'path';
5
5
  import { promisify } from 'util';
6
6
 
@@ -17,7 +17,7 @@ import 'crypto';
17
17
  import 'fs';
18
18
  import 'chalk';
19
19
  import 'mri';
20
- import viteBasicSslPlugin from '../../node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs';
20
+ import viteBasicSslPlugin from '../../node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.1.0_vite@5.0.12/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs';
21
21
 
22
22
  /**
23
23
  * Base plugins configuration for apps and libs.
@@ -16,7 +16,7 @@ import { ViteMode, Stage, Target } from '../types.mjs';
16
16
  const nxEnv = loadEnv(mode, process.cwd(), 'NX');
17
17
  const nxCommandString = process?.env?.['npm_package_scripts_nx'];
18
18
  const modeIsProd = mode === ViteMode.PROD;
19
- const stage = (nxEnv?.['NX_TASK_TARGET_CONFIGURATION']) ?? (modeIsProd ? Stage.PROD : Stage.DEV);
19
+ const stage = nxEnv?.['NX_TASK_TARGET_CONFIGURATION'] ?? (modeIsProd ? Stage.PROD : Stage.DEV);
20
20
  const target = nxEnv?.['NX_TASK_TARGET_TARGET'] ?? Target.BUILD;
21
21
  const flags = getViteCmdFlags(nxCommandString);
22
22
  const showIn = {
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",
4
4
  "type": "module",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.mjs",