Use repo for gpg key

This commit is contained in:
2021-02-22 11:47:49 +01:00
parent 1961c551ba
commit 22aaf60c8a
7 changed files with 89 additions and 9062 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
/node_modules /node_modules
/dist /dist
/.cache /.cache
/.env
*.log

File diff suppressed because one or more lines are too long

View File

@@ -24,9 +24,11 @@
"@types/webpack-subresource-integrity": "^1.2.0", "@types/webpack-subresource-integrity": "^1.2.0",
"@types/workbox-webpack-plugin": "^5.1.4", "@types/workbox-webpack-plugin": "^5.1.4",
"antd": "^4.5.4", "antd": "^4.5.4",
"axios": "^0.21.1",
"babel-loader": "^8.1.0", "babel-loader": "^8.1.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3", "babel-plugin-transform-inline-environment-variables": "^0.4.3",
"css-loader": "^4.2.1", "css-loader": "^4.2.1",
"dotenv": "^8.2.0",
"html-webpack-plugin": "^4.3.0", "html-webpack-plugin": "^4.3.0",
"offline-plugin": "^5.0.7", "offline-plugin": "^5.0.7",
"parcel-bundler": "^1.12.4", "parcel-bundler": "^1.12.4",

View File

@@ -1,6 +1,6 @@
import React, { createContext } from 'react'; import React, { createContext } from 'react';
const data = require('../../data.json'); declare var data: any;
interface GithubContextType { interface GithubContextType {
username: string; username: string;

View File

@@ -1,59 +1,78 @@
require('dotenv').config();
import webpack, { Configuration } from 'webpack'; import webpack, { Configuration } from 'webpack';
import axios from 'axios';
import HtmlWebpackPlugin from 'html-webpack-plugin'; import HtmlWebpackPlugin from 'html-webpack-plugin';
import WorkboxWebpackPlugin from 'workbox-webpack-plugin'; import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
import path from 'path'; import path from 'path';
const data = require('./data.json'); const repo = process.env.GITHUB_REPOSITORY;
if (!repo) {
throw new Error('No GITHUB_REPOSITRY env variable found');
}
const [username] = repo.split('/');
const __DEV__ = process.env.NODE_ENV !== 'production'; const __DEV__ = process.env.NODE_ENV !== 'production';
const config: Configuration = { const createConfig = async ():Promise<Configuration> => {
mode: __DEV__ ? 'development' : 'production', const { data: keyList } = await axios.get(`https://api.github.com/users/${username}/gpg_keys`);
entry: { if (keyList.length === 0) {
app: [ throw new Error(`The user ${username} does not have any GPG keys`);
...(__DEV__ ? ['react-hot-loader/patch'] : []), }
path.join(__dirname, 'src', 'index.tsx'), const data = {
], username,
}, keys: keyList.map((key: any) => key.raw_key),
output: { };
path: path.join(__dirname, 'dist'), const config: Configuration = {
crossOriginLoading: 'anonymous', mode: __DEV__ ? 'development' : 'production',
}, entry: {
resolve: { app: [
extensions: ['.tsx', '.ts', '.js'], ...(__DEV__ ? ['react-hot-loader/patch'] : []),
alias: { path.join(__dirname, 'src', 'index.tsx'),
'react-dom': '@hot-loader/react-dom', ],
}, },
}, output: {
plugins: [ path: path.join(__dirname, 'dist'),
new webpack.DefinePlugin({ crossOriginLoading: 'anonymous',
__DEV__: JSON.stringify(__DEV__), },
}), resolve: {
new HtmlWebpackPlugin({ extensions: ['.tsx', '.ts', '.js'],
title: `Parcel for ${data.username}`, alias: {
minify: true, 'react-dom': '@hot-loader/react-dom',
template: path.join(__dirname, 'html.html'), },
}), },
new WorkboxWebpackPlugin.GenerateSW({ plugins: [
swDest: 'sw.js', new webpack.DefinePlugin({
clientsClaim: true, __DEV__: JSON.stringify(__DEV__),
skipWaiting: true, data: JSON.stringify(data),
}), }),
], new HtmlWebpackPlugin({
module: { title: `Parcel for ${data.username}`,
rules: [{ minify: true,
test: /\.tsx?$/, template: path.join(__dirname, 'html.html'),
use: ['babel-loader'], }),
}, { new WorkboxWebpackPlugin.GenerateSW({
test: /\.css$/, swDest: 'sw.js',
use: ['style-loader', 'css-loader'], clientsClaim: true,
}], skipWaiting: true,
}, }),
],
module: {
rules: [{
test: /\.tsx?$/,
use: ['babel-loader'],
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader'],
}],
},
};
(config as any).devServer = {
hot: true,
contentBase: './dist',
};
return config;
}; };
(config as any).devServer = { export default createConfig;
hot: true,
contentBase: './dist',
};
export default config;

File diff suppressed because it is too large Load Diff

View File

@@ -2148,6 +2148,13 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428"
integrity sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA== integrity sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==
axios@^0.21.1:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==
dependencies:
follow-redirects "^1.10.0"
babel-extract-comments@^1.0.0: babel-extract-comments@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/babel-extract-comments/-/babel-extract-comments-1.0.0.tgz#0a2aedf81417ed391b85e18b4614e693a0351a21" resolved "https://registry.yarnpkg.com/babel-extract-comments/-/babel-extract-comments-1.0.0.tgz#0a2aedf81417ed391b85e18b4614e693a0351a21"
@@ -3584,6 +3591,11 @@ dotenv@^5.0.0:
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef"
integrity sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow== integrity sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow==
dotenv@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a"
integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==
duplexer2@~0.1.4: duplexer2@~0.1.4:
version "0.1.4" version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
@@ -4112,6 +4124,11 @@ follow-redirects@^1.0.0:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
follow-redirects@^1.10.0:
version "1.13.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147"
integrity sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA==
for-in@^1.0.2: for-in@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"