create-middag-ui 0.16.0 → 0.17.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.
- package/lib/scaffold.js +37 -36
- package/package.json +1 -1
package/lib/scaffold.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* scaffold.js — File creation for all scaffolded files.
|
|
3
3
|
*
|
|
4
4
|
* Creates directory structure, config files, page examples, app entry,
|
|
5
|
-
* and Inertia mock adapters.
|
|
5
|
+
* and Inertia mock adapters. Dev-only adapters live under mock/.
|
|
6
6
|
*
|
|
7
7
|
* Every I/O operation is wrapped with error handling.
|
|
8
8
|
*/
|
|
@@ -226,9 +226,10 @@ export default defineConfig({
|
|
|
226
226
|
resolve: {
|
|
227
227
|
alias: {
|
|
228
228
|
"@/": resolve(__dirname, "src") + "/",
|
|
229
|
+
"@mock/": resolve(__dirname, "mock") + "/",
|
|
229
230
|
${adapterComment}
|
|
230
|
-
"@inertiajs/react": resolve(__dirname, "
|
|
231
|
-
"@inertiajs/core": resolve(__dirname, "
|
|
231
|
+
"@inertiajs/react": resolve(__dirname, "mock/adapters/inertia-react.ts"),
|
|
232
|
+
"@inertiajs/core": resolve(__dirname, "mock/adapters/inertia-core.ts"),
|
|
232
233
|
},
|
|
233
234
|
},
|
|
234
235
|
});
|
|
@@ -934,12 +935,12 @@ export const settingsContract: PageContract = {
|
|
|
934
935
|
*/
|
|
935
936
|
export function scaffoldProApp(targetDir) {
|
|
936
937
|
ensureDir(join(targetDir, "src"));
|
|
937
|
-
ensureDir(join(targetDir, "
|
|
938
|
+
ensureDir(join(targetDir, "mock", "adapters"));
|
|
938
939
|
|
|
939
940
|
// Inertia adapter shims — re-export from pre-built mock bundle
|
|
940
941
|
// so usePage() shares the same MockPageContext as MockPageProvider.
|
|
941
|
-
const adapterReactPath = join(targetDir, "
|
|
942
|
-
if (!skipIfExists(adapterReactPath, "
|
|
942
|
+
const adapterReactPath = join(targetDir, "mock", "adapters", "inertia-react.ts");
|
|
943
|
+
if (!skipIfExists(adapterReactPath, "mock/adapters/inertia-react.ts")) {
|
|
943
944
|
writeFile(adapterReactPath, `/**
|
|
944
945
|
* Mock @inertiajs/react — re-exports from pre-built @middag-io/react/mock.
|
|
945
946
|
*
|
|
@@ -947,16 +948,16 @@ export function scaffoldProApp(targetDir) {
|
|
|
947
948
|
* MockPageProvider (both live in the pre-built ESM bundle).
|
|
948
949
|
*/
|
|
949
950
|
export { usePage, Head, Link, router } from "@middag-io/react/mock";
|
|
950
|
-
`, "
|
|
951
|
+
`, "mock/adapters/inertia-react.ts");
|
|
951
952
|
}
|
|
952
953
|
|
|
953
|
-
const adapterCorePath = join(targetDir, "
|
|
954
|
-
if (!skipIfExists(adapterCorePath, "
|
|
954
|
+
const adapterCorePath = join(targetDir, "mock", "adapters", "inertia-core.ts");
|
|
955
|
+
if (!skipIfExists(adapterCorePath, "mock/adapters/inertia-core.ts")) {
|
|
955
956
|
writeFile(adapterCorePath, `/**
|
|
956
957
|
* Mock @inertiajs/core — re-exports from pre-built @middag-io/react/mock.
|
|
957
958
|
*/
|
|
958
959
|
export { router, setMockNavigate } from "@middag-io/react/mock";
|
|
959
|
-
`, "
|
|
960
|
+
`, "mock/adapters/inertia-core.ts");
|
|
960
961
|
}
|
|
961
962
|
|
|
962
963
|
const mainPath = join(targetDir, "src", "main.tsx");
|
|
@@ -1053,13 +1054,13 @@ export function App() {
|
|
|
1053
1054
|
}
|
|
1054
1055
|
|
|
1055
1056
|
/**
|
|
1056
|
-
* Scaffold FREE adapters:
|
|
1057
|
+
* Scaffold FREE adapters: mock/adapters/ with react-router.
|
|
1057
1058
|
*/
|
|
1058
1059
|
export function scaffoldFreeAdapters(targetDir) {
|
|
1059
|
-
ensureDir(join(targetDir, "
|
|
1060
|
+
ensureDir(join(targetDir, "mock", "adapters"));
|
|
1060
1061
|
|
|
1061
|
-
const corePath = join(targetDir, "
|
|
1062
|
-
if (!skipIfExists(corePath, "
|
|
1062
|
+
const corePath = join(targetDir, "mock", "adapters", "inertia-core.ts");
|
|
1063
|
+
if (!skipIfExists(corePath, "mock/adapters/inertia-core.ts")) {
|
|
1063
1064
|
writeFile(corePath, `/**
|
|
1064
1065
|
* Mock @inertiajs/core for standalone dev server.
|
|
1065
1066
|
* Vite alias redirects @inertiajs/core here.
|
|
@@ -1078,11 +1079,11 @@ export const router = {
|
|
|
1078
1079
|
visit: (url: string) => { _navigate ? _navigate(url) : console.log("[mock] VISIT", url); },
|
|
1079
1080
|
on: () => () => {},
|
|
1080
1081
|
};
|
|
1081
|
-
`, "
|
|
1082
|
+
`, "mock/adapters/inertia-core.ts");
|
|
1082
1083
|
}
|
|
1083
1084
|
|
|
1084
|
-
const reactPath = join(targetDir, "
|
|
1085
|
-
if (!skipIfExists(reactPath, "
|
|
1085
|
+
const reactPath = join(targetDir, "mock", "adapters", "inertia-react.ts");
|
|
1086
|
+
if (!skipIfExists(reactPath, "mock/adapters/inertia-react.ts")) {
|
|
1086
1087
|
writeFile(reactPath, `/**
|
|
1087
1088
|
* Mock @inertiajs/react for standalone dev server (FREE).
|
|
1088
1089
|
* Context-based usePage + react-router Link.
|
|
@@ -1127,7 +1128,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, MockLinkProps>(function
|
|
|
1127
1128
|
});
|
|
1128
1129
|
|
|
1129
1130
|
export { router };
|
|
1130
|
-
`, "
|
|
1131
|
+
`, "mock/adapters/inertia-react.ts");
|
|
1131
1132
|
}
|
|
1132
1133
|
}
|
|
1133
1134
|
|
|
@@ -1139,20 +1140,20 @@ export { router };
|
|
|
1139
1140
|
* defining their own context (which would cause context mismatch).
|
|
1140
1141
|
*/
|
|
1141
1142
|
export function scaffoldProAdapters(targetDir) {
|
|
1142
|
-
ensureDir(join(targetDir, "
|
|
1143
|
+
ensureDir(join(targetDir, "mock", "adapters"));
|
|
1143
1144
|
|
|
1144
|
-
const corePath = join(targetDir, "
|
|
1145
|
-
if (!skipIfExists(corePath, "
|
|
1145
|
+
const corePath = join(targetDir, "mock", "adapters", "inertia-core.ts");
|
|
1146
|
+
if (!skipIfExists(corePath, "mock/adapters/inertia-core.ts")) {
|
|
1146
1147
|
writeFile(corePath, `/**
|
|
1147
1148
|
* Mock @inertiajs/core — PRO re-export from @middag-io/react/mock.
|
|
1148
1149
|
* Shares the same navigate function as MockProductShell.
|
|
1149
1150
|
*/
|
|
1150
1151
|
export { router, setMockNavigate } from "@middag-io/react/mock";
|
|
1151
|
-
`, "
|
|
1152
|
+
`, "mock/adapters/inertia-core.ts (PRO)");
|
|
1152
1153
|
}
|
|
1153
1154
|
|
|
1154
|
-
const reactPath = join(targetDir, "
|
|
1155
|
-
if (!skipIfExists(reactPath, "
|
|
1155
|
+
const reactPath = join(targetDir, "mock", "adapters", "inertia-react.ts");
|
|
1156
|
+
if (!skipIfExists(reactPath, "mock/adapters/inertia-react.ts")) {
|
|
1156
1157
|
writeFile(reactPath, `/**
|
|
1157
1158
|
* Mock @inertiajs/react — PRO re-export from @middag-io/react/mock.
|
|
1158
1159
|
* Shares the same React context as MockPageProvider so usePage()
|
|
@@ -1160,7 +1161,7 @@ export { router, setMockNavigate } from "@middag-io/react/mock";
|
|
|
1160
1161
|
*/
|
|
1161
1162
|
export { usePage, Head, Link } from "@middag-io/react/mock";
|
|
1162
1163
|
export { router } from "./inertia-core";
|
|
1163
|
-
`, "
|
|
1164
|
+
`, "mock/adapters/inertia-react.ts (PRO)");
|
|
1164
1165
|
}
|
|
1165
1166
|
}
|
|
1166
1167
|
|
|
@@ -1270,8 +1271,8 @@ createRoot(document.getElementById("root")!).render(
|
|
|
1270
1271
|
import { BrowserRouter, Routes, Route, useNavigate } from "react-router";
|
|
1271
1272
|
import { ContractPage, I18nProvider } from "@middag-io/react";
|
|
1272
1273
|
import type { PageContract } from "@middag-io/react";
|
|
1273
|
-
import { PageProvider } from "
|
|
1274
|
-
import { setMockNavigate } from "
|
|
1274
|
+
import { PageProvider } from "@mock/adapters/inertia-react";
|
|
1275
|
+
import { setMockNavigate } from "@mock/adapters/inertia-core";
|
|
1275
1276
|
import { dashboardContract } from "./pages/dashboard";
|
|
1276
1277
|
import { connectorsContract } from "./pages/connectors";
|
|
1277
1278
|
import { settingsContract } from "./pages/settings";
|
|
@@ -1726,7 +1727,7 @@ body.middag-active [data-slot="sidebar-container"] {
|
|
|
1726
1727
|
/** @deprecated Use scaffoldFreeApp + scaffoldFreeAdapters instead */
|
|
1727
1728
|
export function scaffoldAppFiles(targetDir) {
|
|
1728
1729
|
ensureDir(join(targetDir, "src"));
|
|
1729
|
-
ensureDir(join(targetDir, "
|
|
1730
|
+
ensureDir(join(targetDir, "mock", "adapters"));
|
|
1730
1731
|
|
|
1731
1732
|
// src/main.tsx — entry point
|
|
1732
1733
|
const mainPath = join(targetDir, "src", "main.tsx");
|
|
@@ -1821,9 +1822,9 @@ export function App() {
|
|
|
1821
1822
|
);
|
|
1822
1823
|
}
|
|
1823
1824
|
|
|
1824
|
-
//
|
|
1825
|
-
const inertiaReactPath = join(targetDir, "
|
|
1826
|
-
if (!skipIfExists(inertiaReactPath, "
|
|
1825
|
+
// mock/adapters/inertia-react.ts
|
|
1826
|
+
const inertiaReactPath = join(targetDir, "mock", "adapters", "inertia-react.ts");
|
|
1827
|
+
if (!skipIfExists(inertiaReactPath, "mock/adapters/inertia-react.ts")) {
|
|
1827
1828
|
writeFile(
|
|
1828
1829
|
inertiaReactPath,
|
|
1829
1830
|
`/**
|
|
@@ -1934,13 +1935,13 @@ export const Link = React.forwardRef<HTMLAnchorElement, MockLinkProps>(function
|
|
|
1934
1935
|
|
|
1935
1936
|
export { router };
|
|
1936
1937
|
`,
|
|
1937
|
-
"
|
|
1938
|
+
"mock/adapters/inertia-react.ts",
|
|
1938
1939
|
);
|
|
1939
1940
|
}
|
|
1940
1941
|
|
|
1941
|
-
//
|
|
1942
|
-
const inertiaCorePath = join(targetDir, "
|
|
1943
|
-
if (!skipIfExists(inertiaCorePath, "
|
|
1942
|
+
// mock/adapters/inertia-core.ts
|
|
1943
|
+
const inertiaCorePath = join(targetDir, "mock", "adapters", "inertia-core.ts");
|
|
1944
|
+
if (!skipIfExists(inertiaCorePath, "mock/adapters/inertia-core.ts")) {
|
|
1944
1945
|
writeFile(
|
|
1945
1946
|
inertiaCorePath,
|
|
1946
1947
|
`/**
|
|
@@ -1960,7 +1961,7 @@ export const router = {
|
|
|
1960
1961
|
on: () => () => {},
|
|
1961
1962
|
};
|
|
1962
1963
|
`,
|
|
1963
|
-
"
|
|
1964
|
+
"mock/adapters/inertia-core.ts",
|
|
1964
1965
|
);
|
|
1965
1966
|
}
|
|
1966
1967
|
}
|