Skip to content

Commit

Permalink
release/create-authhero 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
markusahlstrand committed Jul 14, 2024
1 parent fbd8b41 commit 95b1659
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"manage": "pnpm --filter @authhero/manage",
"react-admin": "pnpm --filter @authhero/react-admin",
"authhero": "pnpm --filter authhero",
"create-authhero": "pnpm --filter @authhero/create-authhero"
"create-authhero": "pnpm --filter create-authhero"
},
"keywords": [],
"author": "",
Expand Down
7 changes: 7 additions & 0 deletions packages/create-authhero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# create-authhero

## 0.1.0

### Minor Changes

- Added template files to created project
4 changes: 3 additions & 1 deletion packages/create-authhero/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-authhero",
"version": "0.0.1",
"version": "0.1.0",
"type": "module",
"main": "dist/create-authhero.js",
"bin": {
Expand All @@ -11,6 +11,8 @@
"start": "pnpm build && node dist/create-authhero.js"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/node": "^20.14.9",
"typescript": "^5.5.2",
"vite": "^5.3.2"
Expand Down
25 changes: 22 additions & 3 deletions packages/create-authhero/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,29 @@ program
2,
),
);
fs.writeFileSync(
path.join(projectPath, "index.js"),
`console.log('Welcome to AuthHero!');`,

// For now we create sqlite by default
const sourceDir = path.join(
import.meta.url.replace("file://", "").replace("/create-authhero.js", ""),
"./sqlite",
);

function copyFiles(source, target) {
const files = fs.readdirSync(source);
files.forEach((file) => {
const sourceFile = path.join(source, file);
const targetFile = path.join(target, file);
if (fs.lstatSync(sourceFile).isDirectory()) {
fs.mkdirSync(targetFile);
copyFiles(sourceFile, targetFile);
} else {
fs.copyFileSync(sourceFile, targetFile);
}
});
}

copyFiles(sourceDir, projectPath);

console.log(`Project "${projectName}" has been created.`);
});

Expand Down
1 change: 0 additions & 1 deletion packages/create-authhero/src/vite-env.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-authhero/templates/sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "MIT",
"dependencies": {
"@hono/zod-openapi": "^0.14.9",
"authhero": "workspace:^",
"authhero": "^0.1.0",
"hono": "^4.4.10"
}
}
2 changes: 1 addition & 1 deletion packages/create-authhero/templates/sqlite/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Hono } from "hono";
import { init } from "../../../../authhero";
import { init } from "authhero";

// function init() {
// const app = new OpenAPIHono<{ Bindings: Bindings }>();
Expand Down
12 changes: 11 additions & 1 deletion packages/create-authhero/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { defineConfig } from "vite";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";

export default defineConfig({
publicDir: "templates",
build: {
target: "node16",
lib: {
entry: "src/index.ts",
formats: ["es"],
fileName: "create-authhero",
},
rollupOptions: {
external: ["commander", "inquirer", "fs", "path"],
external: ["commander", "inquirer", "fs", "path", "url"],
plugins: [
nodeResolve({
preferBuiltins: true,
}),
commonjs(),
],
},
},
});
Loading

0 comments on commit 95b1659

Please sign in to comment.