mirror of
https://github.com/morten-olsen/parcel.git
synced 2026-02-08 01:36:24 +01:00
Use repo for gpg key
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
/node_modules
|
||||
/dist
|
||||
/.cache
|
||||
/.env
|
||||
*.log
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
"@types/webpack-subresource-integrity": "^1.2.0",
|
||||
"@types/workbox-webpack-plugin": "^5.1.4",
|
||||
"antd": "^4.5.4",
|
||||
"axios": "^0.21.1",
|
||||
"babel-loader": "^8.1.0",
|
||||
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
|
||||
"css-loader": "^4.2.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"html-webpack-plugin": "^4.3.0",
|
||||
"offline-plugin": "^5.0.7",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { createContext } from 'react';
|
||||
|
||||
const data = require('../../data.json');
|
||||
declare var data: any;
|
||||
|
||||
interface GithubContextType {
|
||||
username: string;
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
require('dotenv').config();
|
||||
import webpack, { Configuration } from 'webpack';
|
||||
import axios from 'axios';
|
||||
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
||||
import WorkboxWebpackPlugin from 'workbox-webpack-plugin';
|
||||
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 createConfig = async ():Promise<Configuration> => {
|
||||
const { data: keyList } = await axios.get(`https://api.github.com/users/${username}/gpg_keys`);
|
||||
if (keyList.length === 0) {
|
||||
throw new Error(`The user ${username} does not have any GPG keys`);
|
||||
}
|
||||
const data = {
|
||||
username,
|
||||
keys: keyList.map((key: any) => key.raw_key),
|
||||
};
|
||||
const config: Configuration = {
|
||||
mode: __DEV__ ? 'development' : 'production',
|
||||
entry: {
|
||||
@@ -28,6 +43,7 @@ const config: Configuration = {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
__DEV__: JSON.stringify(__DEV__),
|
||||
data: JSON.stringify(data),
|
||||
}),
|
||||
new HtmlWebpackPlugin({
|
||||
title: `Parcel for ${data.username}`,
|
||||
@@ -56,4 +72,7 @@ const config: Configuration = {
|
||||
contentBase: './dist',
|
||||
};
|
||||
|
||||
export default config;
|
||||
return config;
|
||||
};
|
||||
|
||||
export default createConfig;
|
||||
|
||||
9007
yarn-error.log
9007
yarn-error.log
File diff suppressed because it is too large
Load Diff
17
yarn.lock
17
yarn.lock
@@ -2148,6 +2148,13 @@ aws4@^1.8.0:
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428"
|
||||
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:
|
||||
version "1.0.0"
|
||||
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"
|
||||
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:
|
||||
version "0.1.4"
|
||||
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"
|
||||
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:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||
|
||||
Reference in New Issue
Block a user