dh-remixer-sdk 0.0.1
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.
- package/package.json +13 -0
- package/scripts/postinstall.mjs +138 -0
- package/templates/base/.htaccess +25 -0
- package/templates/base/cleanup.json +7 -0
- package/templates/base/filemap.json +8 -0
- package/templates/base/index.html +17 -0
- package/templates/base/index.tsx +34 -0
- package/templates/base/package.json +31 -0
- package/templates/base/robots.txt +2 -0
- package/templates/ecommerce/package.json +6 -0
- package/templates/landing-page/package.json +6 -0
package/package.json
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import fssync from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
function isObj(x) {
|
|
7
|
+
return x != null && typeof x === "object" && !Array.isArray(x);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function jsonMerge(low, high) {
|
|
11
|
+
if (!isObj(low) || !isObj(high)) {
|
|
12
|
+
return high === undefined ? low : high;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
Object.keys({ ...low, ...high }).map((key) => {
|
|
17
|
+
const lv = low[key];
|
|
18
|
+
const hv = high[key];
|
|
19
|
+
|
|
20
|
+
if (hv === undefined) return [key, lv];
|
|
21
|
+
if (Array.isArray(lv) || Array.isArray(hv)) return [key, hv];
|
|
22
|
+
if (isObj(lv) && isObj(hv)) return [key, jsonMerge(lv, hv)];
|
|
23
|
+
|
|
24
|
+
return [key, hv];
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function extractFile(baseFileName, tmplFileName, target) {
|
|
30
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
31
|
+
|
|
32
|
+
if (fssync.existsSync(tmplFileName)) {
|
|
33
|
+
await fs.copyFile(tmplFileName, target);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (fssync.existsSync(baseFileName)) {
|
|
38
|
+
await fs.copyFile(baseFileName, target);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function extractJsonFile(baseFileName, tmplFileName, target) {
|
|
43
|
+
const baseExists = fssync.existsSync(baseFileName);
|
|
44
|
+
const templateExists = fssync.existsSync(tmplFileName);
|
|
45
|
+
|
|
46
|
+
if (!baseExists && !templateExists) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let jsonContents = {};
|
|
51
|
+
|
|
52
|
+
if (baseExists) {
|
|
53
|
+
const baseContents = JSON.parse(await fs.readFile(baseFileName, "utf8"));
|
|
54
|
+
jsonContents = jsonMerge(jsonContents, baseContents);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (templateExists) {
|
|
58
|
+
const tmplContents = JSON.parse(await fs.readFile(tmplFileName, "utf8"));
|
|
59
|
+
jsonContents = jsonMerge(jsonContents, tmplContents);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const stringContents = JSON.stringify(jsonContents, null, 2) + "\n";
|
|
63
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
64
|
+
await fs.writeFile(target, stringContents, "utf8");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function createNewPackageJsonFile(projectRoot, baseRoot, tmplRoot, vSdk) {
|
|
68
|
+
const projPkg = JSON.parse(
|
|
69
|
+
await fs.readFile(path.join(projectRoot, "package.json"), "utf8"),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const basePkg = JSON.parse(
|
|
73
|
+
await fs.readFile(path.join(baseRoot, "package.json"), "utf8"),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const tmplPkg = JSON.parse(
|
|
77
|
+
await fs.readFile(path.join(tmplRoot, "package.json"), "utf8"),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const newPkgObj = jsonMerge(projPkg, jsonMerge(basePkg, tmplPkg));
|
|
81
|
+
newPkgObj.dependencies = jsonMerge(newPkgObj.dependencies || {}, {
|
|
82
|
+
"dh-remixer-sdk": vSdk,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const newPkgString = JSON.stringify(newPkgObj, null, 2) + "\n";
|
|
86
|
+
const newPkgPath = path.join(projectRoot, "new.package.json");
|
|
87
|
+
await fs.writeFile(newPkgPath, newPkgString, "utf8");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function main() {
|
|
91
|
+
const projectRoot = path.resolve(process.env.INIT_CWD ?? process.cwd());
|
|
92
|
+
const projPkgPath = path.join(projectRoot, "package.json");
|
|
93
|
+
const projPkg = JSON.parse(await fs.readFile(projPkgPath, "utf8"));
|
|
94
|
+
const templateType = projPkg?.remixerMetadata?.template;
|
|
95
|
+
const sdkRoot = path.resolve(
|
|
96
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
97
|
+
"..",
|
|
98
|
+
);
|
|
99
|
+
const sdkPkgPath = path.join(sdkRoot, "package.json");
|
|
100
|
+
const sdkVersion = JSON.parse(await fs.readFile(sdkPkgPath, "utf8")).version;
|
|
101
|
+
const templateRoot = path.join(sdkRoot, "templates", templateType);
|
|
102
|
+
const baseRoot = path.join(sdkRoot, "templates", "base");
|
|
103
|
+
const cleanupPath = path.join(baseRoot, "cleanup.json");
|
|
104
|
+
const filemapPath = path.join(baseRoot, "filemap.json");
|
|
105
|
+
const cleanup = JSON.parse(await fs.readFile(cleanupPath, "utf8"));
|
|
106
|
+
const filemap = JSON.parse(await fs.readFile(filemapPath, "utf8"));
|
|
107
|
+
|
|
108
|
+
if (!templateType)
|
|
109
|
+
throw new Error("Missing remixerMetadata.template in package.json");
|
|
110
|
+
|
|
111
|
+
// Delete old files
|
|
112
|
+
await Promise.all(
|
|
113
|
+
cleanup.map((relativePath) =>
|
|
114
|
+
fs
|
|
115
|
+
.rm(path.join(projectRoot, relativePath), {
|
|
116
|
+
recursive: true,
|
|
117
|
+
force: true,
|
|
118
|
+
})
|
|
119
|
+
.catch(() => {}),
|
|
120
|
+
),
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
// Extract new files
|
|
124
|
+
await Promise.all([
|
|
125
|
+
...Object.entries(filemap).map(([fileName, target]) => {
|
|
126
|
+
const targetPath = path.join(projectRoot, target);
|
|
127
|
+
const baseFileName = path.join(baseRoot, fileName);
|
|
128
|
+
const templateFileName = path.join(templateRoot, fileName);
|
|
129
|
+
|
|
130
|
+
return fileName.endsWith(".json")
|
|
131
|
+
? extractJsonFile(baseFileName, templateFileName, targetPath)
|
|
132
|
+
: extractFile(baseFileName, templateFileName, targetPath);
|
|
133
|
+
}),
|
|
134
|
+
createNewPackageJsonFile(projectRoot, baseRoot, templateRoot, sdkVersion),
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
await main();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<IfModule mod_rewrite.c>
|
|
2
|
+
|
|
3
|
+
RewriteEngine On
|
|
4
|
+
RewriteBase /
|
|
5
|
+
|
|
6
|
+
# Prevent directory listings
|
|
7
|
+
Options -Indexes
|
|
8
|
+
|
|
9
|
+
# Deny access to .htaccess and other hidden files
|
|
10
|
+
<FilesMatch "^\.">
|
|
11
|
+
Require all denied
|
|
12
|
+
</FilesMatch>
|
|
13
|
+
|
|
14
|
+
# Don't rewrite files that exist
|
|
15
|
+
RewriteCond %{REQUEST_FILENAME} -f
|
|
16
|
+
RewriteRule ^ - [L]
|
|
17
|
+
|
|
18
|
+
# Don't rewrite other directories that exist
|
|
19
|
+
RewriteCond %{REQUEST_FILENAME} -d
|
|
20
|
+
RewriteRule ^ - [L]
|
|
21
|
+
|
|
22
|
+
# Rewrite everything else to index.html
|
|
23
|
+
RewriteRule ^ index.html [L]
|
|
24
|
+
|
|
25
|
+
</IfModule>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
|
|
7
|
+
<title>%VITE_METADATA_TITLE%</title>
|
|
8
|
+
<meta name="description" content="%VITE_METADATA_DESCRIPTION%" />
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="%VITE_METADATA_FAVICON%" />
|
|
10
|
+
|
|
11
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
12
|
+
<script type="module" src="/index.tsx"></script>
|
|
13
|
+
</head>
|
|
14
|
+
<body class="antialiased">
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import tailwindConfig from "@/tailwind.config";
|
|
4
|
+
import App from "@/App";
|
|
5
|
+
import { GOOGLE_FONTS_URL } from "@/fonts";
|
|
6
|
+
import { LanguageProvider } from "@/context/LanguageContext";
|
|
7
|
+
import "@/index.css";
|
|
8
|
+
|
|
9
|
+
// Auto-inject Google Fonts from fonts.googleapis.com
|
|
10
|
+
if (typeof window !== "undefined" && (window as any).document) {
|
|
11
|
+
const link = document.createElement("link");
|
|
12
|
+
link.href = GOOGLE_FONTS_URL;
|
|
13
|
+
link.rel = "stylesheet";
|
|
14
|
+
document.head.appendChild(link);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Auto-configure global Tailwind https://cdn.tailwindcss.com
|
|
18
|
+
if (typeof window !== "undefined" && (window as any).tailwind) {
|
|
19
|
+
(window as any).tailwind.config = tailwindConfig;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rootElement = document.getElementById("root");
|
|
23
|
+
if (!rootElement) {
|
|
24
|
+
throw new Error("Could not find root element to mount to");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const root = ReactDOM.createRoot(rootElement);
|
|
28
|
+
root.render(
|
|
29
|
+
<React.StrictMode>
|
|
30
|
+
<LanguageProvider>
|
|
31
|
+
<App />
|
|
32
|
+
</LanguageProvider>
|
|
33
|
+
</React.StrictMode>
|
|
34
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "remixer-ai-website",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "vite build --outDir out",
|
|
8
|
+
"start": "vite preview --host 0.0.0.0 --mode production --port ${PORT:-4173}",
|
|
9
|
+
"dev": "vite --host 0.0.0.0 --port ${PORT:-4173} --mode development",
|
|
10
|
+
"lint": "echo 'Linting not implemented!'",
|
|
11
|
+
"remixer-sdk:update": "npm install remixer-sdk@latest && mv new.package.json package.json"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@internationalized/date": "3.10.0",
|
|
15
|
+
"@supabase/supabase-js": "2.86.0",
|
|
16
|
+
"date-fns": "4.1.0",
|
|
17
|
+
"framer-motion": "12.23.24",
|
|
18
|
+
"lucide-react": "0.554.0",
|
|
19
|
+
"react": "19.2.0",
|
|
20
|
+
"react-aria-components": "1.11.0",
|
|
21
|
+
"react-dom": "19.2.0",
|
|
22
|
+
"react-helmet": "6.1.0",
|
|
23
|
+
"react-router-dom": "7.9.6"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "22.19.1",
|
|
27
|
+
"@vitejs/plugin-react": "5.1.1",
|
|
28
|
+
"typescript": "5.8.3",
|
|
29
|
+
"vite": "6.4.1"
|
|
30
|
+
}
|
|
31
|
+
}
|