create-authhero 0.28.0 โ 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Copy AuthHero
|
|
4
|
+
* Copy AuthHero assets to dist directory
|
|
5
5
|
*
|
|
6
|
-
* This script copies
|
|
7
|
-
* so they can be
|
|
6
|
+
* This script copies static assets from the authhero package to the dist directory
|
|
7
|
+
* so they can be served as static files. Most deployment targets do not support
|
|
8
|
+
* serving files directly from node_modules.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import fs from "fs";
|
|
@@ -14,11 +15,25 @@ import { fileURLToPath } from "url";
|
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
const __dirname = path.dirname(__filename);
|
|
16
17
|
|
|
18
|
+
const sourceDir = path.join(
|
|
19
|
+
__dirname,
|
|
20
|
+
"node_modules",
|
|
21
|
+
"authhero",
|
|
22
|
+
"dist",
|
|
23
|
+
"assets",
|
|
24
|
+
);
|
|
25
|
+
const targetDir = path.join(__dirname, "dist", "assets");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Recursively copy directory contents
|
|
29
|
+
*/
|
|
17
30
|
function copyDirectory(src, dest) {
|
|
31
|
+
// Create destination directory if it doesn't exist
|
|
18
32
|
if (!fs.existsSync(dest)) {
|
|
19
33
|
fs.mkdirSync(dest, { recursive: true });
|
|
20
34
|
}
|
|
21
35
|
|
|
36
|
+
// Read source directory
|
|
22
37
|
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
23
38
|
|
|
24
39
|
for (const entry of entries) {
|
|
@@ -33,29 +48,44 @@ function copyDirectory(src, dest) {
|
|
|
33
48
|
}
|
|
34
49
|
}
|
|
35
50
|
|
|
36
|
-
|
|
37
|
-
const authHeroAssets = path.join(__dirname, "node_modules/authhero/dist/assets");
|
|
38
|
-
const widgetSource = path.join(
|
|
39
|
-
__dirname,
|
|
40
|
-
"node_modules/@authhero/widget/dist/authhero-widget"
|
|
41
|
-
);
|
|
42
|
-
const targetDir = path.join(__dirname, "dist/assets");
|
|
43
|
-
const widgetTarget = path.join(targetDir, "u/widget");
|
|
44
|
-
|
|
45
|
-
// Copy authhero assets
|
|
46
|
-
if (fs.existsSync(authHeroAssets)) {
|
|
51
|
+
try {
|
|
47
52
|
console.log("๐ฆ Copying AuthHero assets...");
|
|
48
|
-
copyDirectory(authHeroAssets, targetDir);
|
|
49
|
-
} else {
|
|
50
|
-
console.log("โ ๏ธ AuthHero assets not found at:", authHeroAssets);
|
|
51
|
-
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
if (!fs.existsSync(sourceDir)) {
|
|
55
|
+
console.error(`โ Source directory not found: ${sourceDir}`);
|
|
56
|
+
console.error("Make sure the authhero package is installed.");
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Clean target directory to remove stale files from previous builds
|
|
61
|
+
if (fs.existsSync(targetDir)) {
|
|
62
|
+
fs.rmSync(targetDir, { recursive: true });
|
|
63
|
+
console.log("๐งน Cleaned old assets");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
copyDirectory(sourceDir, targetDir);
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
// Also copy widget files from @authhero/widget package
|
|
69
|
+
const widgetSourceDir = path.join(
|
|
70
|
+
__dirname,
|
|
71
|
+
"node_modules",
|
|
72
|
+
"@authhero",
|
|
73
|
+
"widget",
|
|
74
|
+
"dist",
|
|
75
|
+
"authhero-widget",
|
|
76
|
+
);
|
|
77
|
+
const widgetTargetDir = path.join(targetDir, "u", "widget");
|
|
78
|
+
|
|
79
|
+
if (fs.existsSync(widgetSourceDir)) {
|
|
80
|
+
console.log("๐ฆ Copying widget assets...");
|
|
81
|
+
copyDirectory(widgetSourceDir, widgetTargetDir);
|
|
82
|
+
} else {
|
|
83
|
+
console.warn(`โ ๏ธ Widget directory not found: ${widgetSourceDir}`);
|
|
84
|
+
console.warn("Widget features may not work. Install @authhero/widget to enable.");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.log(`โ
Assets copied to ${targetDir}`);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error("โ Error copying assets:", error.message);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copy AuthHero assets to dist directory
|
|
5
5
|
*
|
|
6
6
|
* This script copies static assets from the authhero package to the dist directory
|
|
7
|
-
* so they can be served
|
|
7
|
+
* so they can be served as static files. Most deployment targets do not support
|
|
8
8
|
* serving files directly from node_modules.
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -57,6 +57,12 @@ try {
|
|
|
57
57
|
process.exit(1);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
// Clean target directory to remove stale files from previous builds
|
|
61
|
+
if (fs.existsSync(targetDir)) {
|
|
62
|
+
fs.rmSync(targetDir, { recursive: true });
|
|
63
|
+
console.log("๐งน Cleaned old assets");
|
|
64
|
+
}
|
|
65
|
+
|
|
60
66
|
copyDirectory(sourceDir, targetDir);
|
|
61
67
|
|
|
62
68
|
// Also copy widget files from @authhero/widget package
|
package/dist/create-authhero.js
CHANGED
|
@@ -57,9 +57,9 @@ const E = new R(), p = {
|
|
|
57
57
|
scripts: {
|
|
58
58
|
postinstall: "node copy-assets.js",
|
|
59
59
|
"copy-assets": "node copy-assets.js",
|
|
60
|
-
dev: "wrangler dev --port 3000 --local-protocol https",
|
|
61
|
-
"dev:remote": "wrangler dev --port 3000 --local-protocol https --remote --config wrangler.local.toml",
|
|
62
|
-
deploy: "wrangler deploy --config wrangler.local.toml",
|
|
60
|
+
dev: "node copy-assets.js && wrangler dev --port 3000 --local-protocol https",
|
|
61
|
+
"dev:remote": "node copy-assets.js && wrangler dev --port 3000 --local-protocol https --remote --config wrangler.local.toml",
|
|
62
|
+
deploy: "node copy-assets.js && wrangler deploy --config wrangler.local.toml",
|
|
63
63
|
"db:migrate:local": "wrangler d1 migrations apply AUTH_DB --local",
|
|
64
64
|
"db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote --config wrangler.local.toml",
|
|
65
65
|
migrate: "wrangler d1 migrations apply AUTH_DB --local",
|