-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update authhero to support both cjs and esm
- Loading branch information
1 parent
95b1659
commit 516e8a2
Showing
5 changed files
with
116 additions
and
8 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 |
---|---|---|
@@ -1,11 +1,41 @@ | ||
import path from "path"; | ||
import { defineConfig } from "vite"; | ||
import { resolve } from "path"; | ||
import dts from "vite-plugin-dts"; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
const getPackageName = () => { | ||
return "authhero"; | ||
}; | ||
|
||
const getPackageNameCamelCase = () => { | ||
try { | ||
return getPackageName().replace(/-./g, (char) => char[1].toUpperCase()); | ||
} catch (err) { | ||
throw new Error("Name property in package.json is missing."); | ||
} | ||
}; | ||
|
||
const fileName = { | ||
es: `${getPackageName()}.mjs`, | ||
cjs: `${getPackageName()}.cjs`, | ||
iife: `${getPackageName()}.iife.js`, | ||
}; | ||
|
||
const formats = Object.keys(fileName) as Array<keyof typeof fileName>; | ||
|
||
module.exports = defineConfig({ | ||
base: "./", | ||
build: { | ||
lib: { entry: resolve(__dirname, "src/index.ts"), formats: ["es"] }, | ||
outDir: "./build/dist", | ||
lib: { | ||
entry: path.resolve(__dirname, "src/index.ts"), | ||
name: getPackageNameCamelCase(), | ||
formats, | ||
fileName: (format) => fileName[format], | ||
}, | ||
}, | ||
resolve: { | ||
alias: [ | ||
{ find: "@", replacement: path.resolve(__dirname, "src") }, | ||
{ find: "@@", replacement: path.resolve(__dirname) }, | ||
], | ||
}, | ||
plugins: [dts()], | ||
}); |
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,68 @@ | ||
Sure! Here's a `README.md` file for your CLI package: | ||
|
||
````markdown | ||
# create-authhero | ||
|
||
`create-authhero` is a command-line tool for creating a new AuthHero project. It sets up a new project with the necessary configuration and template files, including SQLite templates. | ||
|
||
## Usage | ||
|
||
To create a new AuthHero project, run the following command: | ||
|
||
```sh | ||
npm create authhero <project-name> | ||
``` | ||
|
||
If you don't specify a project name, you will be prompted to enter one. | ||
|
||
### Example | ||
|
||
```sh | ||
npm create authhero my-auth-project | ||
``` | ||
|
||
This will create a new directory named `my-auth-project` with the following structure: | ||
|
||
``` | ||
my-auth-project | ||
├── package.json | ||
└── src | ||
└── ... (template files) | ||
``` | ||
|
||
The generated project is a small wrapper around the [authhero](https://www.npmjs.com/package/authhero) npm library which makes it easy to keep up to date with the latest changes. All the files in the `src` directory are templates that you can modify to fit your needs. | ||
|
||
### Options | ||
|
||
- `project-name` (optional): The name of the new project. If not provided, you will be prompted to enter it. | ||
|
||
## Project Setup | ||
|
||
When you run the `create-authhero` command, you will be prompted to enter some additional information for your new project: | ||
|
||
- Project name | ||
|
||
These details will be included in the `package.json` file of your new project. | ||
|
||
## Development | ||
|
||
To contribute to this project, clone the repository and install the dependencies: | ||
|
||
```sh | ||
git clone https://github.com/markusahlstrand/authhero | ||
cd create-authhero | ||
npm install | ||
``` | ||
|
||
## License | ||
|
||
MIT | ||
|
||
## Author | ||
|
||
Markus Ahlstrand | ||
|
||
## Acknowledgments | ||
|
||
- [Commander.js](https://github.com/tj/commander.js) - Command-line interfaces made easy | ||
- [Inquirer.js](https://github.com/SBoudrias/Inquirer.js) - A collection of common interactive command line user interfaces |
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