Skip to content

Commit

Permalink
keep frontend pkg json
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed May 11, 2024
1 parent e5328d0 commit 057ede6
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 27 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/offchain-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
run: 'gcloud info'
- name: Deploy to GCF
run: |
gcloud functions deploy bounty-icp-gh-app \
cd offchain/github
gcloud functions deploy offchain/github \
--runtime nodejs20 \
--allow-unauthenticated \
--trigger-http \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/offchain-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
with:
node-version: lts/*
cache: npm
- run: cd offchain/github
- run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/offchain-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ jobs:
with:
cache: npm
node-version: 20
- run: cd offchain/github
- run: npm ci
- run: npm test
File renamed without changes.
41 changes: 41 additions & 0 deletions offchain/github/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "offchain",
"version": "1.0.0",
"private": true,
"description": "ICP Bounty gh-app on Google Cloud Functions",
"keywords": [
"Internet Computer",
"Node",
"JavaScript",
"Canister"
],
"scripts": {
"start": "probot run ./src/main/app.js",
"test": "node ./src/test/test.js",
"clean": "rm -rf node_modules",
"reinstall": "npm run clean && npm install",
"generate": "dfx generate backend",
"rebuild": "npm run clean && npm install && npm run build",
"lint": "standard"
},
"author": "Prom3th3us",
"license": "ISC",
"repository": "github:Prom3th3us/bounty-icp",
"dependencies": {
"probot": "^13.2.2",
"@dfinity/agent": "^0.15.6",
"@dfinity/candid": "^0.15.6",
"@dfinity/principal": "^0.15.6"
},
"devDependencies": {
"nock": "^14.0.0-beta.6",
"smee-client": "^2.0.1",
"uvu": "^0.5.6",
"standard": "^17.1.0"
},
"release": {
"branches": [
"release"
]
}
}
59 changes: 33 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
{
"name": "offchain",
"version": "1.0.0",
"private": true,
"description": "ICP Bounty gh-app on Google Cloud Functions",
"name": "frontend",
"version": "0.2.0",
"description": "Internet Computer starter application",
"keywords": [
"Internet Computer",
"Node",
"Rust",
"JavaScript",
"Canister"
],
"scripts": {
"start": "probot run ./offchain/github/src/main/app.js",
"test": "node ./offchain/github/src/test/test.js",
"clean": "rm -rf node_modules",
"reinstall": "npm run clean && npm install",
"generate": "dfx generate backend",
"rebuild": "npm run clean && npm install && npm run build",
"lint": "standard"
"build": "webpack",
"prebuild": "dfx generate",
"start": "webpack serve --mode development --env development",
"deploy:local": "dfx deploy --network=local",
"deploy:ic": "dfx deploy --network=ic",
"generate": "dfx generate backend"
},
"author": "Prom3th3us",
"license": "ISC",
"repository": "github:Prom3th3us/bounty-icp",
"dependencies": {
"probot": "^13.2.2",
"@dfinity/agent": "^0.15.6",
"@dfinity/candid": "^0.15.6",
"@dfinity/principal": "^0.15.6"
},
"devDependencies": {
"nock": "^14.0.0-beta.6",
"smee-client": "^2.0.1",
"uvu": "^0.5.6",
"standard": "^17.1.0"
"assert": "2.0.0",
"buffer": "6.0.3",
"copy-webpack-plugin": "^11.0.0",
"dotenv": "^16.0.3",
"events": "3.3.0",
"html-webpack-plugin": "5.5.0",
"process": "0.11.10",
"stream-browserify": "3.0.0",
"terser-webpack-plugin": "^5.3.3",
"util": "0.12.4",
"webpack": "^5.73.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.8.1"
},
"release": {
"branches": [
"release"
]
}
}
"engines": {
"node": "16 || ^18 || ^20"
},
"browserslist": [
"last 2 chrome version",
"last 2 firefox version",
"last 2 safari version",
"last 2 edge version"
]
}
96 changes: 96 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
require("dotenv").config();
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");

const isDevelopment = process.env.NODE_ENV !== "production";

const frontendDirectory = "frontend";

const frontend_entry = path.join("src", frontendDirectory, "src", "index.html");

module.exports = {
target: "web",
mode: isDevelopment ? "development" : "production",
entry: {
// The frontend.entrypoint points to the HTML file for this build, so we need
// to replace the extension to `.js`.
index: path.join(__dirname, frontend_entry).replace(/\.html$/, ".js"),
},
devtool: isDevelopment ? "source-map" : false,
optimization: {
minimize: !isDevelopment,
minimizer: [new TerserPlugin()],
},
resolve: {
extensions: [".js", ".ts", ".jsx", ".tsx"],
fallback: {
assert: require.resolve("assert/"),
buffer: require.resolve("buffer/"),
events: require.resolve("events/"),
stream: require.resolve("stream-browserify/"),
util: require.resolve("util/"),
},
},
output: {
filename: "index.js",
path: path.join(__dirname, "dist", frontendDirectory),
},

// Depending in the language or framework you are using for
// front-end development, add module loaders to the default
// webpack configuration. For example, if you are using React
// modules and CSS as described in the "Adding a stylesheet"
// tutorial, uncomment the following lines:
// module: {
// rules: [
// { test: /\.(ts|tsx|jsx)$/, loader: "ts-loader" },
// { test: /\.css$/, use: ['style-loader','css-loader'] }
// ]
// },
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, frontend_entry),
cache: false,
}),
new webpack.EnvironmentPlugin([
...Object.keys(process.env).filter((key) => {
if (key.includes("CANISTER")) return true;
if (key.includes("DFX")) return true;
return false;
}),
]),
new webpack.ProvidePlugin({
Buffer: [require.resolve("buffer/"), "Buffer"],
process: require.resolve("process/browser"),
}),
new CopyPlugin({
patterns: [
{
from: `src/${frontendDirectory}/src/.ic-assets.json*`,
to: ".ic-assets.json5",
noErrorOnMissing: true,
},
],
}),
],
// proxy /api to port 4943 during development.
// if you edit dfx.json to define a project-specific local network, change the port to match.
devServer: {
proxy: {
"/api": {
target: "http://127.0.0.1:4943",
changeOrigin: true,
pathRewrite: {
"^/api": "/api",
},
},
},
static: path.resolve(__dirname, "src", frontendDirectory, "assets"),
hot: true,
watchFiles: [path.resolve(__dirname, "src", frontendDirectory)],
liveReload: true,
},
};

0 comments on commit 057ede6

Please sign in to comment.