@nizza/devkit 0.1.0-alpha.12 → 0.1.0-alpha.14
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/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
- 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
- package/dist/cjs/shared/utils.cjs +2 -2
- package/dist/cjs/vitejs/config-builder/configs/base.cjs +3 -3
- package/dist/cjs/vitejs/config-builder/plugins.cjs +13 -0
- package/dist/cjs/vitejs/config-builder/shared/types.cjs +1 -0
- 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
- 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
- package/dist/esm/vitejs/config-builder/configs/base.mjs +4 -4
- package/dist/esm/vitejs/config-builder/plugins.mjs +13 -1
- package/dist/esm/vitejs/config-builder/shared/types.mjs +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
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(
|
|
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), {
|
|
@@ -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.
|
|
@@ -85,9 +86,21 @@ require('mri');
|
|
|
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
|
+
return viteCmd.flags?.[types.Flag.HTTPS];
|
|
98
|
+
}
|
|
99
|
+
};
|
|
88
100
|
|
|
89
101
|
exports.basePlugins = basePlugins;
|
|
90
102
|
exports.bundleAnalysisPlugin = bundleAnalysisPlugin;
|
|
91
103
|
exports.dtsPlugin = dtsPlugin;
|
|
104
|
+
exports.httpsServerPlugin = httpsServerPlugin;
|
|
92
105
|
exports.injectCssByJsPlugin = injectCssByJsPlugin;
|
|
93
106
|
exports.injectCssIntoShadowDomPlugin = injectCssIntoShadowDomPlugin;
|