generated from SoftwareBrothers/adminjs-feature-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SoftwareBrothers/feat/adminjs-bundler
feat: create AdminJS utility tool
- Loading branch information
Showing
27 changed files
with
436 additions
and
3,508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ node_modules | |
.github | ||
commitlint.config.js | ||
.idea | ||
test | ||
test | ||
example | ||
.adminjs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { bundle } from '../../src'; | ||
import { uploadFile } from './deploy-s3'; | ||
|
||
(async () => { | ||
const files = await bundle({ | ||
customComponentsInitializationFilePath: 'src/components/index.ts', | ||
destinationDir: 'src/public', | ||
}); | ||
|
||
console.log(files); | ||
// do something with built files here | ||
// example - upload to S3: | ||
// await Promise.all(files.map(uploadFile)); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { promises as fs } from 'fs'; | ||
import { join } from 'path'; | ||
import AWS from 'aws-sdk'; | ||
import { BundleFile } from "../../src"; | ||
|
||
type UploadOptions = { | ||
keyPrefix: string; | ||
bucket: string; | ||
}; | ||
|
||
const aws = new AWS.S3({ | ||
region: process.env.AWS_DEFAULT_REGION, | ||
accessKeyId: process.env.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, | ||
signatureVersion: 'v4', | ||
}); | ||
|
||
export const uploadFile = async ( | ||
{ destinationPath: filePath, name }: BundleFile, | ||
{ keyPrefix, bucket }: UploadOptions, | ||
): Promise<void> => { | ||
const file = await fs.readFile(filePath); | ||
const s3Path = join(keyPrefix, name); | ||
|
||
console.log(`Uploading ${filePath} to ${s3Path}`); | ||
|
||
return new Promise((resolve, reject) => { | ||
aws.upload( | ||
{ | ||
Bucket: bucket, | ||
Key: s3Path, | ||
Body: file, | ||
ACL: 'public-read', | ||
}, | ||
(err, data) => { | ||
if (err) reject(err); | ||
console.log(`Succesfully uploaded ${name} to ${data.Location}`); | ||
resolve(); | ||
}, | ||
); | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
{ | ||
"name": "adminjs-example", | ||
"name": "@adminjs/bundler-example", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "nodemon", | ||
"lint": "eslint src --ext ts" | ||
"bundle": "ts-node bin/bundle-admin.ts" | ||
}, | ||
"dependencies": { | ||
"@adminjs/design-system": "^2.1.0", | ||
"@adminjs/express": "^4.0.1", | ||
"adminjs": "^5.6.0", | ||
"express": "^4.17.1", | ||
"express-formidable": "^1.2.0", | ||
"nodemon": "^2.0.6", | ||
"aws-sdk": "^2.1073.0", | ||
"ts-node": "^9.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.8" | ||
} | ||
"devDependencies": {} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import AdminJS from 'adminjs'; | ||
|
||
const BASE = './'; | ||
const bundle = (path, componentName) => AdminJS.bundle(`${BASE}/${path}`, componentName); | ||
|
||
export const SOME_CUSTOM_COMPONENT = bundle('some-custom-component', 'SomeCustomComponent'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import React from 'react'; | ||
|
||
const SomeCustomComponent: React.FC<any> = (_props: any) => { | ||
return <p>An example component</p>; | ||
}; | ||
|
||
export default SomeCustomComponent; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.