Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (service): Auto-create projects when using GitHub actions #103

Merged
merged 6 commits into from
Jun 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: lironer
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: ['https://www.paypal.com/donate?hosted_button_id=YZL6KM2UGB5ML']
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@

[![npm](https://img.shields.io/npm/v/bundlemon)](http://www.npmjs.com/package/bundlemon)
[![node](https://img.shields.io/node/v/bundlemon.svg)](https://github.com/LironEr/bundlemon)
[![npm](https://img.shields.io/npm/l/bundlemon)](http://www.npmjs.com/package/bundlemon)
[![npm](https://img.shields.io/npm/dm/bundlemon)](http://www.npmjs.com/package/bundlemon)

BundleMon helps you to monitor your bundle size.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"ts-jest": "^27.0.4",
"typescript": "^4.3.5"
"typescript": "^4.6.4"
},
"engines": {
"yarn": "^1.10.0"
2 changes: 1 addition & 1 deletion packages/bundlemon-markdown-output/package.json
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
},
"dependencies": {
"bytes": "^3.1.0",
"bundlemon-utils": "^0.4.0"
"bundlemon-utils": "^0.4.1"
},
"devDependencies": {
"@types/bytes": "^3.1.0",
2 changes: 1 addition & 1 deletion packages/bundlemon-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bundlemon-utils",
"version": "0.4.0",
"version": "0.4.1",
"description": "",
"keywords": [],
"author": "Liron Er",
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ Object {
"MaxPercentIncrease": "MaxPercentIncrease",
"MaxSize": "MaxSize",
},
"ProjectProvider": Object {
"GitHub": "github",
},
"Status": Object {
"Fail": "Fail",
"Pass": "Pass",
4 changes: 4 additions & 0 deletions packages/bundlemon-utils/src/consts.ts
Original file line number Diff line number Diff line change
@@ -20,3 +20,7 @@ export enum FailReason {
MaxSize = 'MaxSize',
MaxPercentIncrease = 'MaxPercentIncrease',
}

export enum ProjectProvider {
GitHub = 'github',
}
2 changes: 1 addition & 1 deletion packages/bundlemon/package.json
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
"dependencies": {
"axios": "^0.21.1",
"brotli-size": "^4.0.0",
"bundlemon-utils": "^0.4.0",
"bundlemon-utils": "^0.4.1",
"bytes": "^3.1.0",
"chalk": "^4.1.1",
"commander": "^8.0.0",
2 changes: 1 addition & 1 deletion packages/bundlemon/src/common/service.ts
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ export async function createCommitRecord(

return res.data;
} catch (err) {
logError(err, 'create commit record');
logError(err as Error, 'create commit record');
}

return undefined;
4 changes: 2 additions & 2 deletions packages/bundlemon/src/main/outputs/outputManager.ts
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ export class OutputManager {
logger.debug(`Ignoring output "${name}"`);
}
} catch (err) {
throw new Error(`Error while creating "${name}" output: ${err.message}`);
throw new Error(`Error while creating "${name}" output: ${(err as Error).message}`);
}
}
}
@@ -54,7 +54,7 @@ export class OutputManager {
try {
await instance.generate(report);
} catch (err) {
throw new Error(`Error while generating "${name}" output. ${err.message}`);
throw new Error(`Error while generating "${name}" output. ${(err as Error).message}`);
}
}
};
10 changes: 5 additions & 5 deletions service/package.json
Original file line number Diff line number Diff line change
@@ -24,22 +24,22 @@
"@octokit/auth-app": "^3.4.0",
"@octokit/rest": "^18.5.3",
"aws-lambda-fastify": "^1.4.4",
"bundlemon-utils": "^0.4.0",
"bundlemon-utils": "^0.4.1",
"bundlemon-markdown-output": "^0.1.1",
"bytes": "^3.1.0",
"env-var": "^7.0.1",
"fastify": "^3.27.0",
"@fastify/cors": "^7.0.0",
"fastify": "^4.0.0-rc.4",
"@fastify/cors": "^8.0.0",
"mongodb": "^4.3.1"
},
"devDependencies": {
"@types/bytes": "^3.1.0",
"dotenv": "^10.0.0",
"nodemon": "^2.0.7",
"rimraf": "^3.0.2",
"ts-json-schema-generator": "^0.94.1",
"ts-json-schema-generator": "^1.0.0",
"ts-node": "^10.2.0",
"vercel": "^21.3.3",
"typescript": "^4.3.5"
"typescript": "^4.6.4"
}
}
4 changes: 3 additions & 1 deletion service/scripts/generateLocalData.ts
Original file line number Diff line number Diff line change
@@ -3,7 +3,8 @@ import * as dotenv from 'dotenv';
dotenv.config({ path: path.join(__dirname, '../dev.env') });

import { ObjectId } from 'mongodb';
import { getDB, getProjectsCollection } from '../src/framework/mongo';
import { getDB } from '../src/framework/mongo/client';
import { getProjectsCollection } from '../src/framework/mongo/projects';
import { createHash } from '../src/utils/hashUtils';
import { mongoUrl, nodeEnv } from '../src/framework/env';

@@ -20,6 +21,7 @@ async function createProject(char: string) {
_id: new ObjectId(projectId),
apiKey: { hash, startKey },
creationDate,
lastAccessed: new Date(),
});

console.log(`project ${projectId} created with api key: "${apiKey}"`);
2 changes: 1 addition & 1 deletion service/src/app.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import fastify from 'fastify';
import routes from './routes';
import cors from '@fastify/cors';
import * as schemas from './consts/schemas';
import { closeMongoClient } from './framework/mongo';
import { closeMongoClient } from './framework/mongo/client';

function init() {
const app = fastify({
Original file line number Diff line number Diff line change
@@ -12,5 +12,8 @@ Object {
"Months": "months",
"Weeks": "weeks",
},
"CreateCommitRecordAuthType": Object {
"GithubActions": "GITHUB_ACTIONS",
},
}
`;
4 changes: 4 additions & 0 deletions service/src/consts/commitRecords.ts
Original file line number Diff line number Diff line change
@@ -9,3 +9,7 @@ export enum BaseRecordCompareTo {
PreviousCommit = 'PREVIOUS_COMMIT',
LatestCommit = 'LATEST_COMMIT',
}

export enum CreateCommitRecordAuthType {
GithubActions = 'GITHUB_ACTIONS',
}
Loading