@nizza/devkit 0.1.0-alpha.11 → 0.1.0-alpha.13

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 (38) hide show
  1. package/dist/cjs/executors/update-executors-file/index.cjs +2 -2
  2. package/dist/cjs/index.cjs +7 -7
  3. package/dist/cjs/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.cjs +19578 -0
  4. package/dist/cjs/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.cjs +40 -0
  5. package/dist/cjs/shared/utils.cjs +2 -2
  6. package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/base.cjs +3 -3
  7. package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/lib.cjs +2 -1
  8. package/dist/cjs/{vite-utils → vitejs}/config-builder/plugins.cjs +17 -3
  9. package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/types.cjs +1 -0
  10. package/dist/cjs/{vite-utils → vitejs}/plugins/third-party-css-inject/utils.cjs +1 -3
  11. package/dist/esm/executors/update-executors-file/index.mjs +2 -2
  12. package/dist/esm/index.mjs +7 -7
  13. package/dist/esm/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/chunks/certificate.mjs +19576 -0
  14. package/dist/esm/node_modules/.pnpm/@vitejs_plugin-basic-ssl@1.0.2_vite@5.0.4/node_modules/@vitejs/plugin-basic-ssl/dist/index.mjs +35 -0
  15. package/dist/esm/{vite-utils → vitejs}/config-builder/configs/base.mjs +4 -4
  16. package/dist/esm/{vite-utils → vitejs}/config-builder/configs/lib.mjs +2 -1
  17. package/dist/esm/{vite-utils → vitejs}/config-builder/plugins.mjs +17 -4
  18. package/dist/esm/{vite-utils → vitejs}/config-builder/shared/types.mjs +1 -0
  19. package/dist/esm/{vite-utils → vitejs}/plugins/third-party-css-inject/utils.mjs +1 -3
  20. package/package.json +2 -4
  21. /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/app.cjs +0 -0
  22. /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/index.cjs +0 -0
  23. /package/dist/cjs/{vite-utils → vitejs}/config-builder/configs/script.cjs +0 -0
  24. /package/dist/cjs/{vite-utils → vitejs}/config-builder/main.cjs +0 -0
  25. /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/helpers.cjs +0 -0
  26. /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/projectConfig.cjs +0 -0
  27. /package/dist/cjs/{vite-utils → vitejs}/config-builder/shared/utils/viteCommand.cjs +0 -0
  28. /package/dist/cjs/{vite-utils → vitejs}/plugins/shadow-dom-inject-css/index.cjs +0 -0
  29. /package/dist/cjs/{vite-utils → vitejs}/plugins/third-party-css-inject/main.cjs +0 -0
  30. /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/app.mjs +0 -0
  31. /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/index.mjs +0 -0
  32. /package/dist/esm/{vite-utils → vitejs}/config-builder/configs/script.mjs +0 -0
  33. /package/dist/esm/{vite-utils → vitejs}/config-builder/main.mjs +0 -0
  34. /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/helpers.mjs +0 -0
  35. /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/projectConfig.mjs +0 -0
  36. /package/dist/esm/{vite-utils → vitejs}/config-builder/shared/utils/viteCommand.mjs +0 -0
  37. /package/dist/esm/{vite-utils → vitejs}/plugins/shadow-dom-inject-css/index.mjs +0 -0
  38. /package/dist/esm/{vite-utils → vitejs}/plugins/third-party-css-inject/main.mjs +0 -0
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var path = require('node:path');
6
+ var node_fs = require('node:fs');
7
+
8
+ const defaultCacheDir = "node_modules/.vite";
9
+ function viteBasicSslPlugin() {
10
+ return {
11
+ name: "vite:basic-ssl",
12
+ async configResolved(config) {
13
+ const certificate = await getCertificate((config.cacheDir ?? defaultCacheDir) + "/basic-ssl");
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());
17
+ }
18
+ };
19
+ }
20
+ async function getCertificate(cacheDir) {
21
+ const cachePath = path.join(cacheDir, "_cert.pem");
22
+ try {
23
+ const [stat, content] = await Promise.all([
24
+ node_fs.promises.stat(cachePath),
25
+ node_fs.promises.readFile(cachePath, "utf8")
26
+ ]);
27
+ if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1e3) {
28
+ throw new Error("cache is outdated.");
29
+ }
30
+ return content;
31
+ } catch {
32
+ const content = (await Promise.resolve().then(function () { return require('./chunks/certificate.cjs'); })).createCertificate();
33
+ node_fs.promises.mkdir(cacheDir, { recursive: true }).then(() => node_fs.promises.writeFile(cachePath, content)).catch(() => {
34
+ });
35
+ return content;
36
+ }
37
+ }
38
+
39
+ exports.default = viteBasicSslPlugin;
40
+ exports.getCertificate = getCertificate;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var devkit = require('@nx/devkit');
4
- var crypto = require('crypto');
4
+ var require$$1 = require('crypto');
5
5
  var fs = require('fs');
6
6
  var path = require('path');
7
7
 
@@ -29,7 +29,7 @@ var path = require('path');
29
29
  * @returns {string} - A string representing a unique identifier.
30
30
  */ function shortId(length = 8) {
31
31
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
32
- return Array.from(crypto.randomBytes(length), (b)=>chars[b % chars.length]).join('');
32
+ return Array.from(require$$1.randomBytes(length), (b)=>chars[b % chars.length]).join('');
33
33
  }
34
34
 
35
35
  exports.getPkgJson = getPkgJson;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var fs = require('fs');
4
+ var path = require('path');
3
5
  var plugins = require('../plugins.cjs');
4
6
  var types = require('../shared/types.cjs');
5
7
  var helpers = require('../shared/utils/helpers.cjs');
@@ -7,8 +9,6 @@ require('minimatch');
7
9
  require('../../../shared/logger.cjs');
8
10
  require('@nx/devkit');
9
11
  require('crypto');
10
- var fs = require('fs');
11
- var path = require('path');
12
12
  require('chalk');
13
13
  require('mri');
14
14
  require('vite');
@@ -32,7 +32,7 @@ const getBaseConfig = (ctx)=>{
32
32
  const envFilePath = fs.existsSync(path.resolve(path$1, 'src', envPath)) ? envPath : fallbackEnvPath;
33
33
  return {
34
34
  envPrefix,
35
- plugins: helpers.getPlugins(ctx, plugins.basePlugins, plugins.bundleAnalysisPlugin),
35
+ plugins: helpers.getPlugins(ctx, plugins.basePlugins, plugins.httpsServerPlugin, plugins.bundleAnalysisPlugin),
36
36
  resolve: {
37
37
  alias: {
38
38
  ...helpers.when(resolveEnvs.default && !omittedStages.includes(stage), {
@@ -40,7 +40,8 @@ const getLibConfig = (ctx)=>{
40
40
  name,
41
41
  entry,
42
42
  formats: [
43
- 'es'
43
+ 'es',
44
+ 'cjs'
44
45
  ],
45
46
  fileName: (format)=>`index.${format === 'es' ? 'mjs' : 'cjs'}`
46
47
  },
@@ -19,6 +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
23
 
23
24
  /**
24
25
  * Base plugins configuration for apps and libs.
@@ -65,13 +66,13 @@ require('mri');
65
66
  filename: 'bundle-analysis.html'
66
67
  })
67
68
  ],
68
- condition: ({ viteCmd })=>viteCmd.flags?.[types.Flag.ANALYZE] === 'true'
69
+ condition: ({ viteCmd })=>viteCmd.flags?.[types.Flag.ANALYZE]
69
70
  };
70
71
  /**
71
72
  * Plugin configuration for injecting CSS into JS files
72
73
  * using vite-plugin-css-injected-by-js.
73
74
  */ const injectCssByJsPlugin = {
74
- generate: (_)=>[
75
+ generate: ()=>[
75
76
  cssInjectedByJsPlugin()
76
77
  ],
77
78
  condition: ({ projectConfig })=>!projectConfig.shadowDom
@@ -80,14 +81,27 @@ require('mri');
80
81
  * Plugin configuration for injecting CSS into Shadow Dom.
81
82
  * using local plugin.
82
83
  */ const injectCssIntoShadowDomPlugin = {
83
- generate: (_)=>[
84
+ generate: ()=>[
84
85
  index.injectCssIntoShadowDom()
85
86
  ],
86
87
  condition: ({ projectConfig })=>projectConfig.shadowDom
87
88
  };
89
+ /**
90
+ * Use the plugin @vitejs/plugin-basic-ssl to create a SSL
91
+ * certificate and create https server.
92
+ */ const httpsServerPlugin = {
93
+ generate: ()=>[
94
+ index$1.default()
95
+ ],
96
+ condition: ({ viteCmd })=>{
97
+ console.log('🚀 ~ file: plugins.ts:92 ~ viteCmd.flags:', viteCmd.flags);
98
+ return viteCmd.flags?.[types.Flag.HTTPS];
99
+ }
100
+ };
88
101
 
89
102
  exports.basePlugins = basePlugins;
90
103
  exports.bundleAnalysisPlugin = bundleAnalysisPlugin;
91
104
  exports.dtsPlugin = dtsPlugin;
105
+ exports.httpsServerPlugin = httpsServerPlugin;
92
106
  exports.injectCssByJsPlugin = injectCssByJsPlugin;
93
107
  exports.injectCssIntoShadowDomPlugin = injectCssIntoShadowDomPlugin;
@@ -24,6 +24,7 @@ exports.Flag = void 0;
24
24
  Flag["ANALYZE"] = "analyze";
25
25
  Flag["VERBOSE"] = "verbose";
26
26
  Flag["VERBOSE_ALIAS"] = "v";
27
+ Flag["HTTPS"] = "https";
27
28
  })(exports.Flag || (exports.Flag = {}));
28
29
  exports.Target = void 0;
29
30
  (function(Target) {
@@ -66,13 +66,11 @@ async function buildCSSInjectionCode(execute) {
66
66
  */ function injectionCSSCodePlugin(execute) {
67
67
  return {
68
68
  name: 'vite:third-party-css-inject',
69
- // @ts-ignore
70
69
  resolveId (id) {
71
70
  if (id == cssInjectedByJsId) {
72
71
  return id;
73
72
  }
74
73
  },
75
- // @ts-ignore
76
74
  load (id) {
77
75
  if (id == cssInjectedByJsId) {
78
76
  let executeJs = [];
@@ -86,7 +84,7 @@ async function buildCSSInjectionCode(execute) {
86
84
  return `try{if(typeof document != 'undefined'){
87
85
  const waitForElement=${waitForElement.toString()};
88
86
  ${executeJs.join(' ')}
89
- }}catch(e){console.error('vite'-third-party-css-inject-plugin', e);}`;
87
+ }}catch(e){console.error('vite:third-party-css-inject', e);}`;
90
88
  }
91
89
  }
92
90
  };
@@ -15,7 +15,7 @@ const { readFile } = promises;
15
15
  const projectConfig = getProjectConfig(ctx);
16
16
  const rootDir = projectConfig.root;
17
17
  const executorsFilePath = join(rootDir, 'executors.json');
18
- const distExecutorsFilePath = join(rootDir, 'dist', 'executors.json');
18
+ // const distExecutorsFilePath = join(rootDir, 'dist', 'executors.json');
19
19
  const originalContent = JSON.parse(await readFile(executorsFilePath, 'utf8'));
20
20
  // Update paths to point to './dist/' and add '.js'
21
21
  const updatedExecutors = updateExecutorPaths(originalContent.executors, false);
@@ -27,7 +27,7 @@ const { readFile } = promises;
27
27
  executors: updatedExecutors
28
28
  })
29
29
  ]);
30
- return ok(`🚀 Executors updated successfully.`);
30
+ return ok();
31
31
  } catch (error) {
32
32
  return err(error, `❌ Error processing file: ${error}`);
33
33
  }
@@ -3,10 +3,10 @@ export { default as environmentsExecutor } from './executors/environments/index.
3
3
  export { default as publishExecutor } from './executors/publish/index.mjs';
4
4
  export { default as updateExecutorsFileExecutor } from './executors/update-executors-file/index.mjs';
5
5
  export { default as vtexLinkExecutor } from './executors/vtex-link/index.mjs';
6
- export { createConfigBuilder } from './vite-utils/config-builder/main.mjs';
7
- export { Flag, ProjectType, Stage, Target, ViteMode } from './vite-utils/config-builder/shared/types.mjs';
8
- export { chunkName, deepMerge, getNxTsConfigPaths, getPlugins, when } from './vite-utils/config-builder/shared/utils/helpers.mjs';
9
- export { getExternalDependencies, getInitials, initializeConfig, mergeConfigs } from './vite-utils/config-builder/shared/utils/projectConfig.mjs';
10
- export { getViteCmdFlags, getViteCommand } from './vite-utils/config-builder/shared/utils/viteCommand.mjs';
11
- export { thirdPartyCssInjectPlugin } from './vite-utils/plugins/third-party-css-inject/main.mjs';
12
- export { injectCssIntoShadowDom } from './vite-utils/plugins/shadow-dom-inject-css/index.mjs';
6
+ export { createConfigBuilder } from './vitejs/config-builder/main.mjs';
7
+ export { Flag, ProjectType, Stage, Target, ViteMode } from './vitejs/config-builder/shared/types.mjs';
8
+ export { chunkName, deepMerge, getNxTsConfigPaths, getPlugins, when } from './vitejs/config-builder/shared/utils/helpers.mjs';
9
+ export { getExternalDependencies, getInitials, initializeConfig, mergeConfigs } from './vitejs/config-builder/shared/utils/projectConfig.mjs';
10
+ export { getViteCmdFlags, getViteCommand } from './vitejs/config-builder/shared/utils/viteCommand.mjs';
11
+ export { thirdPartyCssInjectPlugin } from './vitejs/plugins/third-party-css-inject/main.mjs';
12
+ export { injectCssIntoShadowDom } from './vitejs/plugins/shadow-dom-inject-css/index.mjs';