Primeiro commit do projeto Angular
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-present, Yuxi (Evan) You and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
# @vitejs/plugin-basic-ssl [](https://npmjs.com/package/@vitejs/plugin-basic-ssl)
|
||||
|
||||
A plugin to generate untrusted certificates which still allows to access the page after proceeding a wall with warning.
|
||||
|
||||
In most scenarios, it is recommended to generate a secure trusted certificate instead and use it to configure [`server.https`](https://vitejs.dev/config/server-options.html#server-https)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// vite.config.js
|
||||
import basicSsl from '@vitejs/plugin-basic-ssl'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
basicSsl({
|
||||
/** name of certification */
|
||||
name: 'test',
|
||||
/** custom trust domains */
|
||||
domains: ['*.custom.com'],
|
||||
/** custom certification directory */
|
||||
certDir: '/Users/.../.devServer/cert',
|
||||
}),
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+19928
File diff suppressed because it is too large
Load Diff
+56
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var path = require('node:path');
|
||||
var node_fs = require('node:fs');
|
||||
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
||||
|
||||
var path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
||||
|
||||
const defaultCacheDir = "node_modules/.vite";
|
||||
function viteBasicSslPlugin(options) {
|
||||
return {
|
||||
name: "vite:basic-ssl",
|
||||
async configResolved(config) {
|
||||
const certificate = await getCertificate(
|
||||
options?.certDir ?? (config.cacheDir ?? defaultCacheDir) + "/basic-ssl",
|
||||
options?.name,
|
||||
options?.domains
|
||||
);
|
||||
const https = () => ({ cert: certificate, key: certificate });
|
||||
if (config.server.https === void 0 || !!config.server.https) {
|
||||
config.server.https = Object.assign({}, config.server.https, https());
|
||||
}
|
||||
if (config.preview.https === void 0 || !!config.preview.https) {
|
||||
config.preview.https = Object.assign({}, config.preview.https, https());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
async function getCertificate(cacheDir, name, domains) {
|
||||
const cachePath = path__default.join(cacheDir, "_cert.pem");
|
||||
try {
|
||||
const [stat, content] = await Promise.all([
|
||||
node_fs.promises.stat(cachePath),
|
||||
node_fs.promises.readFile(cachePath, "utf8")
|
||||
]);
|
||||
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1e3) {
|
||||
throw new Error("cache is outdated.");
|
||||
}
|
||||
return content;
|
||||
} catch {
|
||||
const content = (await import('./chunks/certificate.mjs')).createCertificate(
|
||||
name,
|
||||
domains
|
||||
);
|
||||
node_fs.promises.mkdir(cacheDir, { recursive: true }).then(() => node_fs.promises.writeFile(cachePath, content)).catch(() => {
|
||||
});
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = viteBasicSslPlugin;
|
||||
module.exports["default"] = viteBasicSslPlugin;
|
||||
module.exports.getCertificate = getCertificate;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Plugin } from 'vite';
|
||||
|
||||
interface Options {
|
||||
certDir: string;
|
||||
domains: string[];
|
||||
name: string;
|
||||
}
|
||||
declare function viteBasicSslPlugin(options?: Partial<Options>): Plugin;
|
||||
declare function getCertificate(cacheDir: string, name?: string, domains?: string[]): Promise<string>;
|
||||
|
||||
// @ts-ignore
|
||||
export = viteBasicSslPlugin;
|
||||
export { getCertificate };
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { Plugin } from 'vite';
|
||||
|
||||
interface Options {
|
||||
certDir: string;
|
||||
domains: string[];
|
||||
name: string;
|
||||
}
|
||||
declare function viteBasicSslPlugin(options?: Partial<Options>): Plugin;
|
||||
declare function getCertificate(cacheDir: string, name?: string, domains?: string[]): Promise<string>;
|
||||
|
||||
export { viteBasicSslPlugin as default, getCertificate };
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Plugin } from 'vite';
|
||||
|
||||
interface Options {
|
||||
certDir: string;
|
||||
domains: string[];
|
||||
name: string;
|
||||
}
|
||||
declare function viteBasicSslPlugin(options?: Partial<Options>): Plugin;
|
||||
declare function getCertificate(cacheDir: string, name?: string, domains?: string[]): Promise<string>;
|
||||
|
||||
// @ts-ignore
|
||||
export = viteBasicSslPlugin;
|
||||
export { getCertificate };
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import path from 'node:path';
|
||||
import { promises } from 'node:fs';
|
||||
|
||||
const defaultCacheDir = "node_modules/.vite";
|
||||
function viteBasicSslPlugin(options) {
|
||||
return {
|
||||
name: "vite:basic-ssl",
|
||||
async configResolved(config) {
|
||||
const certificate = await getCertificate(
|
||||
options?.certDir ?? (config.cacheDir ?? defaultCacheDir) + "/basic-ssl",
|
||||
options?.name,
|
||||
options?.domains
|
||||
);
|
||||
const https = () => ({ cert: certificate, key: certificate });
|
||||
if (config.server.https === void 0 || !!config.server.https) {
|
||||
config.server.https = Object.assign({}, config.server.https, https());
|
||||
}
|
||||
if (config.preview.https === void 0 || !!config.preview.https) {
|
||||
config.preview.https = Object.assign({}, config.preview.https, https());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
async function getCertificate(cacheDir, name, domains) {
|
||||
const cachePath = path.join(cacheDir, "_cert.pem");
|
||||
try {
|
||||
const [stat, content] = await Promise.all([
|
||||
promises.stat(cachePath),
|
||||
promises.readFile(cachePath, "utf8")
|
||||
]);
|
||||
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1e3) {
|
||||
throw new Error("cache is outdated.");
|
||||
}
|
||||
return content;
|
||||
} catch {
|
||||
const content = (await import('./chunks/certificate.mjs')).createCertificate(
|
||||
name,
|
||||
domains
|
||||
);
|
||||
promises.mkdir(cacheDir, { recursive: true }).then(() => promises.writeFile(cachePath, content)).catch(() => {
|
||||
});
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
export { viteBasicSslPlugin as default, getCertificate };
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "@vitejs/plugin-basic-ssl",
|
||||
"version": "2.1.4",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"author": "Evan You and Vite Contributors",
|
||||
"description": "A Vite plugin to generate untrusted certificates for HTTPS dev servers",
|
||||
"keywords": [
|
||||
"vite",
|
||||
"vite-plugin",
|
||||
"certificate",
|
||||
"https"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.0.0 || ^20.0.0 || >=22.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vitejs/vite-plugin-basic-ssl.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vitejs/vite-plugin-basic-ssl/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vitejs/vite-plugin-basic-ssl/#readme",
|
||||
"peerDependencies": {
|
||||
"vite": "^6.0.0 || ^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.9",
|
||||
"@vitejs/release-scripts": "^1.6.0",
|
||||
"execa": "^9.6.1",
|
||||
"node-forge": "^1.3.3",
|
||||
"picocolors": "^1.1.1",
|
||||
"prettier": "^3.8.0",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^5.9.3",
|
||||
"unbuild": "^3.6.1",
|
||||
"vite": "^7.3.1",
|
||||
"vitest": "^4.0.17"
|
||||
},
|
||||
"compatiblePackages": {
|
||||
"schemaVersion": 1,
|
||||
"rolldown": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
},
|
||||
"rollup": {
|
||||
"type": "incompatible",
|
||||
"reason": "Uses Vite-specific APIs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "unbuild --stub",
|
||||
"build": "unbuild && tsx scripts/patchCJS.ts",
|
||||
"test": "vitest run",
|
||||
"format": "prettier --write --cache .",
|
||||
"release": "tsx scripts/release.ts",
|
||||
"ci-publish": "tsx scripts/publishCI.ts"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user