@soroush.design/cli 0.2.0-alpha.2 → 0.2.0-alpha.4
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/README.md +9 -112
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +14 -3
- package/dist/index.mjs +1 -1
- package/dist/{io-uDtjQuG6.mjs → io-C_8_JerZ.mjs} +579 -643
- package/package.json +26 -5
- package/templates/astro/js/base/README.md +93 -0
- package/templates/astro/js/base/_gitignore +5 -0
- package/templates/astro/js/base/astro.config.mjs +23 -0
- package/templates/astro/js/base/src/components/About.jsx +24 -0
- package/templates/astro/js/base/src/components/Counter.jsx +26 -0
- package/templates/astro/js/base/src/components/Greeting.jsx +60 -0
- package/templates/astro/js/base/src/components/Header.jsx +99 -0
- package/templates/astro/js/base/src/components/Home.jsx +32 -0
- package/templates/astro/js/base/src/components/Home.test.jsx +39 -0
- package/templates/astro/js/base/src/components/NotFound.jsx +17 -0
- package/templates/astro/js/base/src/data/api.js +84 -0
- package/templates/astro/js/base/src/layouts/Layout.astro +52 -0
- package/templates/astro/js/base/src/pages/404.astro +12 -0
- package/templates/astro/js/base/src/pages/about.astro +12 -0
- package/templates/astro/js/base/src/pages/index.astro +23 -0
- package/templates/astro/js/base/src/theme/Island.jsx +89 -0
- package/templates/astro/js/base/src/theme/scheme.js +32 -0
- package/templates/astro/js/base/vitest.config.js +12 -0
- package/templates/astro/js/sample-data/src/components/ItemDetails.jsx +64 -0
- package/templates/astro/js/sample-data/src/components/ItemList.jsx +100 -0
- package/templates/astro/js/sample-data/src/components/StatusChip.jsx +8 -0
- package/templates/astro/js/sample-data/src/data/items.js +65 -0
- package/templates/astro/js/sample-data/src/pages/items/[id].astro +37 -0
- package/templates/astro/js/sample-data/src/pages/items/index.astro +20 -0
- package/templates/astro/js/with/jotai/src/components/Counter.jsx +26 -0
- package/templates/astro/js/with/jotai/src/state/counter.js +4 -0
- package/templates/astro/js/with/msw/_env +3 -0
- package/templates/astro/js/with/msw/src/mocks/browser.js +5 -0
- package/templates/astro/js/with/msw/src/mocks/handlers.js +24 -0
- package/templates/astro/js/with/msw/src/mocks/server.js +5 -0
- package/templates/astro/js/with/msw/src/mocks/setupTests.js +7 -0
- package/templates/astro/js/with/msw/src/mocks/start.js +14 -0
- package/templates/astro/js/with/react-hook-form/src/components/Form.jsx +313 -0
- package/templates/astro/js/with/react-hook-form/src/pages/form.astro +8 -0
- package/templates/astro/js/with/redux-toolkit/src/components/Counter.jsx +27 -0
- package/templates/astro/js/with/redux-toolkit/src/state/store.js +18 -0
- package/templates/astro/js/with/tanstack-query/src/data/queryClient.js +13 -0
- package/templates/astro/js/with/zustand/src/components/Counter.jsx +24 -0
- package/templates/astro/js/with/zustand/src/state/counter.js +14 -0
- package/templates/astro/ts/base/README.md +93 -0
- package/templates/astro/ts/base/_gitignore +5 -0
- package/templates/astro/ts/base/astro.config.mjs +23 -0
- package/templates/astro/ts/base/src/components/About.tsx +24 -0
- package/templates/astro/ts/base/src/components/Counter.tsx +26 -0
- package/templates/astro/ts/base/src/components/Greeting.tsx +61 -0
- package/templates/astro/ts/base/src/components/Header.tsx +99 -0
- package/templates/astro/ts/base/src/components/Home.test.tsx +39 -0
- package/templates/astro/ts/base/src/components/Home.tsx +33 -0
- package/templates/astro/ts/base/src/components/NotFound.tsx +17 -0
- package/templates/astro/ts/base/src/data/api.ts +92 -0
- package/templates/astro/ts/base/src/layouts/Layout.astro +52 -0
- package/templates/astro/ts/base/src/pages/404.astro +12 -0
- package/templates/astro/ts/base/src/pages/about.astro +12 -0
- package/templates/astro/ts/base/src/pages/index.astro +23 -0
- package/templates/astro/ts/base/src/theme/Island.tsx +90 -0
- package/templates/astro/ts/base/src/theme/scheme.ts +34 -0
- package/templates/astro/ts/base/tsconfig.json +9 -0
- package/templates/astro/ts/base/vitest.config.ts +12 -0
- package/templates/astro/ts/sample-data/src/components/ItemDetails.tsx +65 -0
- package/templates/astro/ts/sample-data/src/components/ItemList.tsx +109 -0
- package/templates/astro/ts/sample-data/src/components/StatusChip.tsx +9 -0
- package/templates/astro/ts/sample-data/src/data/items.ts +71 -0
- package/templates/astro/ts/sample-data/src/pages/items/[id].astro +39 -0
- package/templates/astro/ts/sample-data/src/pages/items/index.astro +20 -0
- package/templates/astro/ts/with/jotai/src/components/Counter.tsx +26 -0
- package/templates/astro/ts/with/jotai/src/state/counter.ts +4 -0
- package/templates/astro/ts/with/msw/_env +3 -0
- package/templates/astro/ts/with/msw/src/mocks/browser.ts +5 -0
- package/templates/astro/ts/with/msw/src/mocks/handlers.ts +24 -0
- package/templates/astro/ts/with/msw/src/mocks/server.ts +5 -0
- package/templates/astro/ts/with/msw/src/mocks/setupTests.ts +7 -0
- package/templates/astro/ts/with/msw/src/mocks/start.ts +14 -0
- package/templates/astro/ts/with/react-hook-form/src/components/Form.tsx +317 -0
- package/templates/astro/ts/with/react-hook-form/src/pages/form.astro +8 -0
- package/templates/astro/ts/with/redux-toolkit/src/components/Counter.tsx +27 -0
- package/templates/astro/ts/with/redux-toolkit/src/state/store.ts +19 -0
- package/templates/astro/ts/with/tanstack-query/src/data/queryClient.ts +13 -0
- package/templates/astro/ts/with/zustand/src/components/Counter.tsx +24 -0
- package/templates/astro/ts/with/zustand/src/state/counter.ts +19 -0
- package/templates/templates.md +66 -0
- package/templates/vike/js/base/README.md +87 -0
- package/templates/vike/js/base/_gitignore +4 -0
- package/templates/vike/js/base/src/data/api.js +76 -0
- package/templates/vike/js/base/src/pages/+Layout.jsx +183 -0
- package/templates/vike/js/base/src/pages/+config.js +12 -0
- package/templates/vike/js/base/src/pages/+onRenderClient.jsx +39 -0
- package/templates/vike/js/base/src/pages/+onRenderHtml.jsx +27 -0
- package/templates/vike/js/base/src/pages/PageShell.jsx +47 -0
- package/templates/vike/js/base/src/pages/_error/+Page.jsx +14 -0
- package/templates/vike/js/base/src/pages/about/+Page.jsx +14 -0
- package/templates/vike/js/base/src/pages/index/+Page.jsx +33 -0
- package/templates/vike/js/base/src/pages/index/Counter.jsx +20 -0
- package/templates/vike/js/base/src/pages/index/Greeting.jsx +48 -0
- package/templates/vike/js/base/src/pages/index/Page.test.jsx +67 -0
- package/templates/vike/js/base/src/pages/usePageContext.jsx +20 -0
- package/templates/vike/js/base/vite.config.js +14 -0
- package/templates/vike/js/base/vitest.config.js +13 -0
- package/templates/vike/js/sample-data/src/data/items.js +58 -0
- package/templates/vike/js/sample-data/src/pages/items/+Page.jsx +49 -0
- package/templates/vike/js/sample-data/src/pages/items/+data.js +26 -0
- package/templates/vike/js/sample-data/src/pages/items/@id/+Page.jsx +40 -0
- package/templates/vike/js/sample-data/src/pages/items/@id/+data.js +33 -0
- package/templates/vike/js/sample-data/src/pages/items/@id/+onBeforePrerenderStart.js +8 -0
- package/templates/vike/js/sample-data/src/pages/items/StatusChip.jsx +8 -0
- package/templates/vike/js/spa/src/pages/+config.js +12 -0
- package/templates/vike/js/spa/src/pages/+onRenderClient.jsx +25 -0
- package/templates/vike/js/spa/src/pages/+onRenderHtml.jsx +16 -0
- package/templates/vike/js/spa/src/pages/about/+Page.jsx +14 -0
- package/templates/vike/js/ssg/src/pages/+config.js +11 -0
- package/templates/vike/js/ssg/src/pages/about/+Page.jsx +13 -0
- package/templates/vike/js/ssr/src/pages/+config.js +12 -0
- package/templates/vike/js/ssr/src/pages/+onRenderHtml.jsx +27 -0
- package/templates/vike/js/ssr/src/pages/about/+Page.jsx +14 -0
- package/templates/vike/js/with/jotai/src/pages/index/Counter.jsx +19 -0
- package/templates/vike/js/with/jotai/src/state/counter.js +4 -0
- package/templates/vike/js/with/jotai/src/state/scheme.js +4 -0
- package/templates/vike/js/with/msw/_env +3 -0
- package/templates/vike/js/with/msw/src/mocks/browser.js +5 -0
- package/templates/vike/js/with/msw/src/mocks/handlers.js +24 -0
- package/templates/vike/js/with/msw/src/mocks/server.js +5 -0
- package/templates/vike/js/with/msw/src/mocks/setupTests.js +7 -0
- package/templates/vike/js/with/msw/src/mocks/start.js +10 -0
- package/templates/vike/js/with/react-hook-form/src/pages/form/+Page.jsx +294 -0
- package/templates/vike/js/with/redux-toolkit/src/pages/index/Counter.jsx +20 -0
- package/templates/vike/js/with/redux-toolkit/src/state/store.js +27 -0
- package/templates/vike/js/with/zustand/src/pages/index/Counter.jsx +17 -0
- package/templates/vike/js/with/zustand/src/state/counter.js +14 -0
- package/templates/vike/js/with/zustand/src/state/scheme.js +14 -0
- package/templates/vike/ts/base/README.md +87 -0
- package/templates/vike/ts/base/_gitignore +4 -0
- package/templates/vike/ts/base/src/data/api.ts +84 -0
- package/templates/vike/ts/base/src/pages/+Layout.tsx +184 -0
- package/templates/vike/ts/base/src/pages/+config.ts +14 -0
- package/templates/vike/ts/base/src/pages/+onRenderClient.tsx +41 -0
- package/templates/vike/ts/base/src/pages/+onRenderHtml.tsx +28 -0
- package/templates/vike/ts/base/src/pages/PageShell.tsx +48 -0
- package/templates/vike/ts/base/src/pages/_error/+Page.tsx +14 -0
- package/templates/vike/ts/base/src/pages/about/+Page.tsx +14 -0
- package/templates/vike/ts/base/src/pages/index/+Page.tsx +33 -0
- package/templates/vike/ts/base/src/pages/index/Counter.tsx +20 -0
- package/templates/vike/ts/base/src/pages/index/Greeting.tsx +49 -0
- package/templates/vike/ts/base/src/pages/index/Page.test.tsx +67 -0
- package/templates/vike/ts/base/src/pages/usePageContext.tsx +27 -0
- package/templates/vike/ts/base/src/vike.d.ts +20 -0
- package/templates/vike/ts/base/tsconfig.json +18 -0
- package/templates/vike/ts/base/vite.config.ts +14 -0
- package/templates/vike/ts/base/vitest.config.ts +13 -0
- package/templates/vike/ts/sample-data/src/data/items.ts +64 -0
- package/templates/vike/ts/sample-data/src/pages/items/+Page.tsx +50 -0
- package/templates/vike/ts/sample-data/src/pages/items/+data.ts +28 -0
- package/templates/vike/ts/sample-data/src/pages/items/@id/+Page.tsx +41 -0
- package/templates/vike/ts/sample-data/src/pages/items/@id/+data.ts +37 -0
- package/templates/vike/ts/sample-data/src/pages/items/@id/+onBeforePrerenderStart.ts +8 -0
- package/templates/vike/ts/sample-data/src/pages/items/StatusChip.tsx +9 -0
- package/templates/vike/ts/spa/src/pages/+config.ts +14 -0
- package/templates/vike/ts/spa/src/pages/+onRenderClient.tsx +27 -0
- package/templates/vike/ts/spa/src/pages/+onRenderHtml.tsx +17 -0
- package/templates/vike/ts/spa/src/pages/about/+Page.tsx +14 -0
- package/templates/vike/ts/ssg/src/pages/+config.ts +13 -0
- package/templates/vike/ts/ssg/src/pages/about/+Page.tsx +13 -0
- package/templates/vike/ts/ssr/src/pages/+config.ts +14 -0
- package/templates/vike/ts/ssr/src/pages/+onRenderHtml.tsx +28 -0
- package/templates/vike/ts/ssr/src/pages/about/+Page.tsx +14 -0
- package/templates/vike/ts/with/jotai/src/pages/index/Counter.tsx +19 -0
- package/templates/vike/ts/with/jotai/src/state/counter.ts +4 -0
- package/templates/vike/ts/with/jotai/src/state/scheme.ts +4 -0
- package/templates/vike/ts/with/msw/_env +3 -0
- package/templates/vike/ts/with/msw/src/mocks/browser.ts +5 -0
- package/templates/vike/ts/with/msw/src/mocks/handlers.ts +24 -0
- package/templates/vike/ts/with/msw/src/mocks/server.ts +5 -0
- package/templates/vike/ts/with/msw/src/mocks/setupTests.ts +7 -0
- package/templates/vike/ts/with/msw/src/mocks/start.ts +10 -0
- package/templates/vike/ts/with/react-hook-form/src/pages/form/+Page.tsx +298 -0
- package/templates/vike/ts/with/redux-toolkit/src/pages/index/Counter.tsx +20 -0
- package/templates/vike/ts/with/redux-toolkit/src/state/store.ts +29 -0
- package/templates/vike/ts/with/zustand/src/pages/index/Counter.tsx +17 -0
- package/templates/vike/ts/with/zustand/src/state/counter.ts +19 -0
- package/templates/vike/ts/with/zustand/src/state/scheme.ts +19 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, rmdirSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { spawnSync } from "node:child_process";
|
|
5
6
|
import { emitKeypressEvents } from "node:readline";
|
|
6
7
|
import { createInterface } from "node:readline/promises";
|
|
@@ -882,32 +883,399 @@ function createAppInstallCommand({ name, isYarnBerry }) {
|
|
|
882
883
|
function formatRunScript({ name }, script) {
|
|
883
884
|
return name === "npm" || name === "bun" ? `${name} run ${script}` : `${name} ${script}`;
|
|
884
885
|
}
|
|
886
|
+
// src/create/libraries.ts
|
|
887
|
+
/** The libraries, in the order create offers them. */
|
|
888
|
+
const LIBRARIES = [
|
|
889
|
+
{
|
|
890
|
+
name: "tanstack-query",
|
|
891
|
+
label: "TanStack Query: fetching and caching data",
|
|
892
|
+
group: "data"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: "swr",
|
|
896
|
+
label: "SWR: fetching and caching data",
|
|
897
|
+
group: "data"
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
name: "msw",
|
|
901
|
+
label: "msw: a mock API in the browser"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
name: "zustand",
|
|
905
|
+
label: "zustand: a store of global state",
|
|
906
|
+
group: "state"
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
name: "jotai",
|
|
910
|
+
label: "Jotai: atoms of global state",
|
|
911
|
+
group: "state"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
name: "redux-toolkit",
|
|
915
|
+
label: "Redux Toolkit: a store of global state",
|
|
916
|
+
group: "state"
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
name: "react-hook-form",
|
|
920
|
+
label: "React Hook Form + Zod: a form, validated"
|
|
921
|
+
}
|
|
922
|
+
];
|
|
923
|
+
const LIBRARY_NAMES = LIBRARIES.map(({ name }) => name);
|
|
924
|
+
/** What the libraries of each group do, as the refusal says it. */
|
|
925
|
+
const GROUP_JOBS = {
|
|
926
|
+
data: "fetch and cache data",
|
|
927
|
+
state: "hold global state"
|
|
928
|
+
};
|
|
929
|
+
/** The names a sentence lists: `a and b`, `a, b and c`. */
|
|
930
|
+
const listNames = (names) => `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
|
|
931
|
+
/** Why `libraries` cannot go together, or `undefined` when they can. */
|
|
932
|
+
function findLibraryConflict(libraries) {
|
|
933
|
+
for (const group of ["data", "state"]) {
|
|
934
|
+
const picked = LIBRARIES.filter((library) => library.group === group && libraries.includes(library.name));
|
|
935
|
+
if (picked.length < 2) continue;
|
|
936
|
+
const names = picked.map(({ label }) => label.split(":")[0]);
|
|
937
|
+
const all = names.length === 2 ? "both" : "all";
|
|
938
|
+
return `${listNames(names)} ${all} ${GROUP_JOBS[group]}: pick one.`;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
// src/create/template/template.ts
|
|
942
|
+
const COMMENTS = [
|
|
943
|
+
["//", ""],
|
|
944
|
+
["{/*", "*/}"],
|
|
945
|
+
["<!--", "-->"]
|
|
946
|
+
];
|
|
947
|
+
/** The marker `line` holds - its word and its condition - or `undefined` when it holds none. */
|
|
948
|
+
function readMarker(line) {
|
|
949
|
+
const text = line.trim();
|
|
950
|
+
for (const [open, close] of COMMENTS) {
|
|
951
|
+
if (!text.startsWith(open) || !text.endsWith(close)) continue;
|
|
952
|
+
const inner = text.slice(open.length, text.length - close.length).trim();
|
|
953
|
+
const match = /^@(if|elif|else|endif)\b(.*)$/.exec(inner);
|
|
954
|
+
if (match) return {
|
|
955
|
+
word: match[1],
|
|
956
|
+
expression: match[2].trim()
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Whether `expression` holds for `flags`: names, `!`, `&&`, `||` and parentheses, as in
|
|
962
|
+
* `tanstack-query && !ssg`.
|
|
963
|
+
*/
|
|
964
|
+
function isConditionMet(expression, flags) {
|
|
965
|
+
const tokens = expression.match(/[a-z0-9-]+|&&|\|\||[!()]/g) ?? [];
|
|
966
|
+
if (tokens.join("") !== expression.replaceAll(/\s/g, "")) throw new Error(`The condition "${expression}" holds something other than names and ! && || ( ).`);
|
|
967
|
+
let position = 0;
|
|
968
|
+
const next = () => tokens[position++];
|
|
969
|
+
const readOr = () => {
|
|
970
|
+
let value = readAnd();
|
|
971
|
+
while (tokens[position] === "||") {
|
|
972
|
+
next();
|
|
973
|
+
value = readAnd() || value;
|
|
974
|
+
}
|
|
975
|
+
return value;
|
|
976
|
+
};
|
|
977
|
+
const readAnd = () => {
|
|
978
|
+
let value = readNot();
|
|
979
|
+
while (tokens[position] === "&&") {
|
|
980
|
+
next();
|
|
981
|
+
value = readNot() && value;
|
|
982
|
+
}
|
|
983
|
+
return value;
|
|
984
|
+
};
|
|
985
|
+
const readNot = () => {
|
|
986
|
+
const token = next();
|
|
987
|
+
if (token === "!") return !readNot();
|
|
988
|
+
if (token === "(") {
|
|
989
|
+
const value = readOr();
|
|
990
|
+
if (next() !== ")") throw new Error(`The condition "${expression}" leaves a ( open.`);
|
|
991
|
+
return value;
|
|
992
|
+
}
|
|
993
|
+
if (token === void 0 || !/^[a-z0-9-]+$/.test(token)) throw new Error(`The condition "${expression}" lacks a name where it has ${token ?? "none"}.`);
|
|
994
|
+
return flags.has(token);
|
|
995
|
+
};
|
|
996
|
+
const value = readOr();
|
|
997
|
+
if (position !== tokens.length) throw new Error(`The condition "${expression}" goes on after its end.`);
|
|
998
|
+
return value;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* A template's text for an app: the lines whose conditions hold, with each placeholder replaced by
|
|
1002
|
+
* its value. Returns `undefined` when nothing is left, so the file is not written.
|
|
1003
|
+
*/
|
|
1004
|
+
function renderTemplate(source, flags, values, name = "the template") {
|
|
1005
|
+
const open = [];
|
|
1006
|
+
const isKept = () => open.every((block) => block.isKept);
|
|
1007
|
+
const lines = [];
|
|
1008
|
+
for (const line of source.split("\n")) {
|
|
1009
|
+
const marker = readMarker(line);
|
|
1010
|
+
if (!marker) {
|
|
1011
|
+
if (isKept()) lines.push(line);
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
const { word, expression } = marker;
|
|
1015
|
+
const block = open.at(-1);
|
|
1016
|
+
if (word === "if") {
|
|
1017
|
+
const holds = isConditionMet(expression, flags);
|
|
1018
|
+
open.push({
|
|
1019
|
+
isKept: holds,
|
|
1020
|
+
isTaken: holds
|
|
1021
|
+
});
|
|
1022
|
+
} else if (!block) throw new Error(`${name} has an @${word} with no @if.`);
|
|
1023
|
+
else if (word === "elif") {
|
|
1024
|
+
block.isKept = !block.isTaken && isConditionMet(expression, flags);
|
|
1025
|
+
block.isTaken ||= block.isKept;
|
|
1026
|
+
} else if (word === "else") {
|
|
1027
|
+
block.isKept = !block.isTaken;
|
|
1028
|
+
block.isTaken = true;
|
|
1029
|
+
} else open.pop();
|
|
1030
|
+
}
|
|
1031
|
+
if (open.length > 0) throw new Error(`${name} leaves an @if open.`);
|
|
1032
|
+
let text = lines.join("\n");
|
|
1033
|
+
for (const [placeholder, value] of Object.entries(values)) text = text.replaceAll(placeholder, value);
|
|
1034
|
+
return text.trim() === "" ? void 0 : text;
|
|
1035
|
+
}
|
|
1036
|
+
/** The names npm or this repository would drop from a template, and what they become. */
|
|
1037
|
+
const RENAMES = {
|
|
1038
|
+
_gitignore: ".gitignore",
|
|
1039
|
+
_env: ".env"
|
|
1040
|
+
};
|
|
1041
|
+
const toOutputPath = (path) => {
|
|
1042
|
+
const name = path.split("/").at(-1);
|
|
1043
|
+
return Object.hasOwn(RENAMES, name) ? `${path.slice(0, -name.length)}${RENAMES[name]}` : path;
|
|
1044
|
+
};
|
|
1045
|
+
/** Every file under `folder`, by its path from there, `/`-separated. */
|
|
1046
|
+
function readFolder(folder) {
|
|
1047
|
+
const files = /* @__PURE__ */ new Map();
|
|
1048
|
+
const visit = (directory) => {
|
|
1049
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
1050
|
+
const path = join(directory, entry.name);
|
|
1051
|
+
if (entry.isDirectory()) visit(path);
|
|
1052
|
+
else files.set(relative(folder, path).replaceAll("\\", "/"), readFileSync(path, "utf8"));
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
visit(folder);
|
|
1056
|
+
return files;
|
|
1057
|
+
}
|
|
1058
|
+
/** The folder of this package that holds the templates, from where this module runs. */
|
|
1059
|
+
function findTemplatesRoot(start = dirname(fileURLToPath(import.meta.url))) {
|
|
1060
|
+
for (let directory = start;; directory = dirname(directory)) {
|
|
1061
|
+
const templates = join(directory, "templates");
|
|
1062
|
+
if (existsSync(join(templates, "templates.md"))) return templates;
|
|
1063
|
+
if (dirname(directory) === directory) throw new Error(`No templates folder above ${start}.`);
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* The files of `layers`, read from `root` in order, each over the ones before it. A layer that is
|
|
1068
|
+
* not there adds nothing. Returns each file's source by the path it is written at.
|
|
1069
|
+
*/
|
|
1070
|
+
function readLayers(root, layers) {
|
|
1071
|
+
const files = /* @__PURE__ */ new Map();
|
|
1072
|
+
for (const layer of layers) {
|
|
1073
|
+
const folder = join(root, layer);
|
|
1074
|
+
if (!existsSync(folder)) continue;
|
|
1075
|
+
for (const [path, source] of readFolder(folder)) files.set(toOutputPath(path), source);
|
|
1076
|
+
}
|
|
1077
|
+
return files;
|
|
1078
|
+
}
|
|
1079
|
+
// src/create/template/starterFiles.ts
|
|
1080
|
+
/** The names that hold for the app `facts` describe, as the templates' markers read them. */
|
|
1081
|
+
function getFlags({ isTypeScript, rendering, libraries, hasSampleData }) {
|
|
1082
|
+
return /* @__PURE__ */ new Set([
|
|
1083
|
+
isTypeScript ? "ts" : "js",
|
|
1084
|
+
rendering,
|
|
1085
|
+
...libraries,
|
|
1086
|
+
...hasSampleData ? ["sample-data"] : []
|
|
1087
|
+
]);
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* The layers of a framework's template for the app `facts` describe, in the order they are laid:
|
|
1091
|
+
* the base, the rendering's own files, the sample data pages, then each library's, in the order
|
|
1092
|
+
* create offers them, whatever order they were given in.
|
|
1093
|
+
*/
|
|
1094
|
+
function getLayers({ rendering, libraries, hasSampleData }) {
|
|
1095
|
+
return [
|
|
1096
|
+
"base",
|
|
1097
|
+
...rendering === "isomorphic" ? [] : [rendering],
|
|
1098
|
+
...hasSampleData ? ["sample-data"] : [],
|
|
1099
|
+
...LIBRARY_NAMES.filter((name) => libraries.includes(name)).map((name) => `with/${name}`)
|
|
1100
|
+
];
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* The files the template of `framework` writes for the app `facts` describe: its layers, laid
|
|
1104
|
+
* one over the other, each file with the lines its markers keep and its placeholders filled.
|
|
1105
|
+
*/
|
|
1106
|
+
function createTemplateFiles(framework, facts, root = findTemplatesRoot()) {
|
|
1107
|
+
const folder = join(root, framework, facts.isTypeScript ? "ts" : "js");
|
|
1108
|
+
const flags = getFlags(facts);
|
|
1109
|
+
const values = {
|
|
1110
|
+
__TITLE_STRING__: facts.title.replaceAll("'", String.raw`\'`),
|
|
1111
|
+
__TITLE__: facts.title,
|
|
1112
|
+
__SCHEME__: facts.scheme
|
|
1113
|
+
};
|
|
1114
|
+
const files = [];
|
|
1115
|
+
for (const [path, source] of readLayers(folder, getLayers(facts))) {
|
|
1116
|
+
const content = renderTemplate(source, flags, values, `${framework}/${path}`);
|
|
1117
|
+
if (content !== void 0) files.push({
|
|
1118
|
+
path,
|
|
1119
|
+
content
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
return files;
|
|
1123
|
+
}
|
|
885
1124
|
// package.json
|
|
886
|
-
var version = "0.2.0-alpha.
|
|
887
|
-
// src/create/
|
|
888
|
-
/** The versions the
|
|
1125
|
+
var version = "0.2.0-alpha.4";
|
|
1126
|
+
// src/create/versions.ts
|
|
1127
|
+
/** The versions the starters install: the ones this package is tested with. */
|
|
889
1128
|
const VERSIONS = {
|
|
1129
|
+
"@astrojs/check": "^0.9.12",
|
|
1130
|
+
"@astrojs/node": "^11.1.13",
|
|
1131
|
+
"@astrojs/react": "^7.1.9",
|
|
890
1132
|
"@emotion/server": "^11.11.0",
|
|
1133
|
+
"@hookform/resolvers": "^7.0.6",
|
|
1134
|
+
"@reduxjs/toolkit": "^2.14.0",
|
|
891
1135
|
"@soroush.tech/eslint-config": "workspace:*",
|
|
1136
|
+
"@tanstack/react-query": "^5.107.1",
|
|
1137
|
+
"@testing-library/dom": "^10.4.2",
|
|
1138
|
+
"@testing-library/react": "^16.3.3",
|
|
892
1139
|
"@types/node": "^26.6.6",
|
|
893
1140
|
"@types/react": "^19.3.0",
|
|
894
1141
|
"@types/react-dom": "^19.3.0",
|
|
895
1142
|
"@vitejs/plugin-react": "^6.3.0",
|
|
896
1143
|
"@vitest/coverage-v8": "^5.1.0",
|
|
1144
|
+
"astro": "^7.4.12",
|
|
1145
|
+
"jotai": "^3.0.2",
|
|
1146
|
+
"jsdom": "^31.0.1",
|
|
1147
|
+
"msw": "^3.0.5",
|
|
897
1148
|
"oxlint": "^1.93.0",
|
|
898
1149
|
"react": "^19.3.1",
|
|
899
1150
|
"react-dom": "^19.3.1",
|
|
1151
|
+
"react-hook-form": "^7.92.0",
|
|
1152
|
+
"react-redux": "^9.3.1",
|
|
1153
|
+
"swr": "^2.5.1",
|
|
1154
|
+
"ts-blank-space": "^0.9.0",
|
|
900
1155
|
"tsdown": "^0.23.7",
|
|
901
1156
|
"typescript": "~7.0.2",
|
|
1157
|
+
"typescript-astro": "npm:typescript@^6.0.3",
|
|
902
1158
|
"vike": "0.4.270",
|
|
903
1159
|
"vite": "~8.3.8",
|
|
904
|
-
"vitest": "^5.1.0"
|
|
1160
|
+
"vitest": "^5.1.0",
|
|
1161
|
+
"zod": "^4.6.7",
|
|
1162
|
+
"zustand": "^5.1.0"
|
|
905
1163
|
};
|
|
906
1164
|
/** A version from this package's own manifest, as a range an app takes. */
|
|
907
1165
|
const toRange = (version) => /^\d/.test(version) ? `^${version}` : version;
|
|
1166
|
+
/** The ranges of `names`, by name, as a package.json lists them. */
|
|
908
1167
|
const pickVersions = (names) => Object.fromEntries(names.map((name) => [name, toRange(VERSIONS[name])]));
|
|
909
|
-
|
|
1168
|
+
/** The packages each library installs: for the app's code, and for its development only. */
|
|
1169
|
+
const LIBRARY_PACKAGES = {
|
|
1170
|
+
"tanstack-query": { dependencies: ["@tanstack/react-query"] },
|
|
1171
|
+
swr: { dependencies: ["swr"] },
|
|
1172
|
+
msw: { devDependencies: ["msw"] },
|
|
1173
|
+
zustand: { dependencies: ["zustand"] },
|
|
1174
|
+
jotai: { dependencies: ["jotai"] },
|
|
1175
|
+
"redux-toolkit": { dependencies: ["@reduxjs/toolkit", "react-redux"] },
|
|
1176
|
+
"react-hook-form": { dependencies: [
|
|
1177
|
+
"react-hook-form",
|
|
1178
|
+
"zod",
|
|
1179
|
+
"@hookform/resolvers"
|
|
1180
|
+
] }
|
|
1181
|
+
};
|
|
1182
|
+
/** The packages of `libraries`: what the app's code imports, and what only its development does. */
|
|
1183
|
+
function getLibraryPackages(libraries) {
|
|
1184
|
+
return {
|
|
1185
|
+
dependencies: libraries.flatMap((library) => LIBRARY_PACKAGES[library].dependencies ?? []),
|
|
1186
|
+
devDependencies: libraries.flatMap((library) => LIBRARY_PACKAGES[library].devDependencies ?? [])
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
/** What every app's tests run on: Vitest, and Testing Library on jsdom. */
|
|
1190
|
+
const TEST_PACKAGES = [
|
|
1191
|
+
"vitest",
|
|
1192
|
+
"@testing-library/react",
|
|
1193
|
+
"@testing-library/dom",
|
|
1194
|
+
"jsdom"
|
|
1195
|
+
];
|
|
1196
|
+
// src/create/astro/astro.ts
|
|
1197
|
+
const TYPESCRIPT_RANGE = VERSIONS["typescript-astro"].replace("npm:typescript@", "");
|
|
1198
|
+
function createPackageJson$1({ packageName, isTypeScript, rendering, libraries, version }) {
|
|
1199
|
+
const isServer = rendering === "ssr";
|
|
1200
|
+
const { dependencies: libraryPackages, devDependencies: libraryDevPackages } = getLibraryPackages(libraries);
|
|
1201
|
+
const packageJson = {
|
|
1202
|
+
name: packageName,
|
|
1203
|
+
private: true,
|
|
1204
|
+
version: "0.0.0",
|
|
1205
|
+
type: "module",
|
|
1206
|
+
scripts: {
|
|
1207
|
+
dev: "astro dev",
|
|
1208
|
+
build: "astro build",
|
|
1209
|
+
preview: "astro preview",
|
|
1210
|
+
...isServer ? { start: "node dist/server/entry.mjs" } : {},
|
|
1211
|
+
...isTypeScript ? { typecheck: "astro check" } : {},
|
|
1212
|
+
test: "vitest run"
|
|
1213
|
+
},
|
|
1214
|
+
dependencies: {
|
|
1215
|
+
"@soroush.tech/design-system": toRange(version),
|
|
1216
|
+
...pickVersions([
|
|
1217
|
+
...isServer ? ["@astrojs/node"] : [],
|
|
1218
|
+
"@astrojs/react",
|
|
1219
|
+
...libraryPackages,
|
|
1220
|
+
"astro",
|
|
1221
|
+
"react",
|
|
1222
|
+
"react-dom"
|
|
1223
|
+
])
|
|
1224
|
+
},
|
|
1225
|
+
devDependencies: {
|
|
1226
|
+
...pickVersions([
|
|
1227
|
+
...isTypeScript ? [
|
|
1228
|
+
"@astrojs/check",
|
|
1229
|
+
"@types/react",
|
|
1230
|
+
"@types/react-dom"
|
|
1231
|
+
] : [],
|
|
1232
|
+
...libraryDevPackages,
|
|
1233
|
+
...TEST_PACKAGES
|
|
1234
|
+
]),
|
|
1235
|
+
...isTypeScript ? { typescript: TYPESCRIPT_RANGE } : {}
|
|
1236
|
+
}
|
|
1237
|
+
};
|
|
1238
|
+
return `${JSON.stringify(packageJson, null, 2)}\n`;
|
|
1239
|
+
}
|
|
1240
|
+
/** The files of the Astro app `facts` describe. */
|
|
1241
|
+
function createFiles$1(facts) {
|
|
1242
|
+
const { isTypeScript, scheme } = facts;
|
|
1243
|
+
const x = isTypeScript ? "ts" : "js";
|
|
1244
|
+
return [
|
|
1245
|
+
{
|
|
1246
|
+
path: "package.json",
|
|
1247
|
+
content: createPackageJson$1(facts)
|
|
1248
|
+
},
|
|
1249
|
+
{
|
|
1250
|
+
path: `src/theme/themes.${x}`,
|
|
1251
|
+
content: createThemesSource({ isTypeScript })
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
path: `src/theme/Providers.${x}`,
|
|
1255
|
+
content: createProvidersSource({
|
|
1256
|
+
isTypeScript,
|
|
1257
|
+
scheme,
|
|
1258
|
+
themesImport: "./themes"
|
|
1259
|
+
})
|
|
1260
|
+
},
|
|
1261
|
+
...createTemplateFiles("astro", facts)
|
|
1262
|
+
];
|
|
1263
|
+
}
|
|
1264
|
+
const astroStarter = {
|
|
1265
|
+
title: "Astro",
|
|
1266
|
+
label: "Astro: HTML pages, with React islands",
|
|
1267
|
+
renderings: [
|
|
1268
|
+
"isomorphic",
|
|
1269
|
+
"ssr",
|
|
1270
|
+
"ssg"
|
|
1271
|
+
],
|
|
1272
|
+
hasLibraries: true,
|
|
1273
|
+
createFiles: createFiles$1
|
|
1274
|
+
};
|
|
1275
|
+
// src/create/vike/vike.ts
|
|
1276
|
+
function createPackageJson({ packageName, isTypeScript, rendering, libraries, version }) {
|
|
910
1277
|
const renderer = rendering === "spa" ? [] : ["@emotion/server"];
|
|
1278
|
+
const { dependencies: libraryPackages, devDependencies: libraryDevPackages } = getLibraryPackages(libraries);
|
|
911
1279
|
const packageJson = {
|
|
912
1280
|
name: packageName,
|
|
913
1281
|
private: true,
|
|
@@ -917,12 +1285,15 @@ function createPackageJson({ packageName, isTypeScript, rendering, version }) {
|
|
|
917
1285
|
dev: "vite",
|
|
918
1286
|
build: "vite build",
|
|
919
1287
|
preview: "vite preview",
|
|
920
|
-
...
|
|
1288
|
+
...rendering === "ssr" ? { start: "node dist/server/index.mjs" } : {},
|
|
1289
|
+
...isTypeScript ? { typecheck: "tsc --noEmit" } : {},
|
|
1290
|
+
test: "vitest run"
|
|
921
1291
|
},
|
|
922
1292
|
dependencies: {
|
|
923
1293
|
"@soroush.tech/design-system": toRange(version),
|
|
924
1294
|
...pickVersions([
|
|
925
1295
|
...renderer,
|
|
1296
|
+
...libraryPackages,
|
|
926
1297
|
"react",
|
|
927
1298
|
"react-dom",
|
|
928
1299
|
"vike"
|
|
@@ -930,6 +1301,8 @@ function createPackageJson({ packageName, isTypeScript, rendering, version }) {
|
|
|
930
1301
|
},
|
|
931
1302
|
devDependencies: pickVersions([
|
|
932
1303
|
"@vitejs/plugin-react",
|
|
1304
|
+
...libraryDevPackages,
|
|
1305
|
+
...TEST_PACKAGES,
|
|
933
1306
|
"vite",
|
|
934
1307
|
...isTypeScript ? [
|
|
935
1308
|
"@types/react",
|
|
@@ -940,594 +1313,15 @@ function createPackageJson({ packageName, isTypeScript, rendering, version }) {
|
|
|
940
1313
|
};
|
|
941
1314
|
return `${JSON.stringify(packageJson, null, 2)}\n`;
|
|
942
1315
|
}
|
|
943
|
-
const VITE_CONFIG = `import react from '@vitejs/plugin-react'
|
|
944
|
-
import vike from 'vike/plugin'
|
|
945
|
-
import { defineConfig } from 'vite'
|
|
946
|
-
|
|
947
|
-
export default defineConfig({
|
|
948
|
-
plugins: [react(), vike()],
|
|
949
|
-
})
|
|
950
|
-
`;
|
|
951
|
-
const TSCONFIG = `{
|
|
952
|
-
"compilerOptions": {
|
|
953
|
-
"target": "ES2022",
|
|
954
|
-
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
955
|
-
"module": "ESNext",
|
|
956
|
-
"moduleResolution": "bundler",
|
|
957
|
-
"verbatimModuleSyntax": true,
|
|
958
|
-
"moduleDetection": "force",
|
|
959
|
-
"noEmit": true,
|
|
960
|
-
"strict": true,
|
|
961
|
-
"noUnusedLocals": true,
|
|
962
|
-
"noUnusedParameters": true,
|
|
963
|
-
"skipLibCheck": true,
|
|
964
|
-
"jsx": "react-jsx",
|
|
965
|
-
"types": ["vite/client"]
|
|
966
|
-
},
|
|
967
|
-
"include": ["src", "vite.config.ts"]
|
|
968
|
-
}
|
|
969
|
-
`;
|
|
970
|
-
const GITIGNORE = `node_modules/
|
|
971
|
-
dist/
|
|
972
|
-
*.log
|
|
973
|
-
.DS_Store
|
|
974
|
-
`;
|
|
975
|
-
const VIKE_TYPES = `// Types for what this app adds to Vike: each page's component, and the +Layout around it.
|
|
976
|
-
import type { ReactNode } from 'react'
|
|
977
|
-
|
|
978
|
-
type Layout = (props: { children: ReactNode }) => ReactNode
|
|
979
|
-
|
|
980
|
-
declare global {
|
|
981
|
-
namespace Vike {
|
|
982
|
-
interface PageContext {
|
|
983
|
-
Page: () => ReactNode
|
|
984
|
-
}
|
|
985
|
-
interface Config {
|
|
986
|
-
Layout?: Layout
|
|
987
|
-
}
|
|
988
|
-
interface ConfigResolved {
|
|
989
|
-
Layout?: Layout
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
export {}
|
|
995
|
-
`;
|
|
996
|
-
/** The layout's link to the sample data pages, when the app has them. */
|
|
997
|
-
const ITEMS_LINK = ` <Link href="/items" underline="hover">
|
|
998
|
-
Items
|
|
999
|
-
</Link>
|
|
1000
|
-
`;
|
|
1001
|
-
/** The layout's light and dark switch, in a page that has JavaScript. */
|
|
1002
|
-
const SCHEME_SWITCH = ` <Button size="sm" variant="outlined" onClick={() => setScheme(otherScheme)}>
|
|
1003
|
-
{otherScheme}
|
|
1004
|
-
</Button>
|
|
1005
|
-
`;
|
|
1006
|
-
/** The settings of each rendering, in +config. */
|
|
1007
|
-
const CONFIG_SETTINGS = {
|
|
1008
|
-
isomorphic: ` // Isomorphic: every page is HTML at build time, then the app moves between pages in the
|
|
1009
|
-
// browser, with no reload.
|
|
1010
|
-
prerender: true,
|
|
1011
|
-
clientRouting: true,
|
|
1012
|
-
hydrationCanBeAborted: true,
|
|
1013
|
-
// +Layout is a setting of this app's own: the component every page renders inside.
|
|
1014
|
-
meta: {
|
|
1015
|
-
Layout: { env: { server: true, client: true } },
|
|
1016
|
-
},`,
|
|
1017
|
-
spa: ` // SPA: every page is an empty HTML shell from the build, which the browser renders; the app
|
|
1018
|
-
// moves between pages with no reload.
|
|
1019
|
-
prerender: true,
|
|
1020
|
-
clientRouting: true,
|
|
1021
|
-
// The page and +Layout, a setting of this app's own, load in the browser only.
|
|
1022
|
-
meta: {
|
|
1023
|
-
Page: { env: { server: false, client: true } },
|
|
1024
|
-
Layout: { env: { server: false, client: true } },
|
|
1025
|
-
},`,
|
|
1026
|
-
ssg: ` // SSG: every page is HTML at build time, with no JavaScript in the browser: a link loads the
|
|
1027
|
-
// next page.
|
|
1028
|
-
prerender: true,
|
|
1029
|
-
// The page and +Layout, a setting of this app's own, load at build time only.
|
|
1030
|
-
meta: {
|
|
1031
|
-
Page: { env: { server: true, client: false } },
|
|
1032
|
-
Layout: { env: { server: true, client: false } },
|
|
1033
|
-
},`
|
|
1034
|
-
};
|
|
1035
|
-
/** What the second page says of how it got there. */
|
|
1036
|
-
const ABOUT_TEXT = {
|
|
1037
|
-
isomorphic: `A second page: it is HTML with its styles from the build, and the app moves to it without a
|
|
1038
|
-
reload.`,
|
|
1039
|
-
spa: `A second page: the browser renders it, with its styles, and the app moves to it without a
|
|
1040
|
-
reload.`,
|
|
1041
|
-
ssg: "A second page: it is HTML with its styles from the build, and a link loads it as a new page."
|
|
1042
|
-
};
|
|
1043
|
-
function createSources({ title, isTypeScript, rendering, scheme, hasSampleData }) {
|
|
1044
|
-
const t = (typeScriptOnly) => isTypeScript ? typeScriptOnly : "";
|
|
1045
|
-
const x = isTypeScript ? "ts" : "js";
|
|
1046
|
-
return {
|
|
1047
|
-
config: `${t("import type { Config } from 'vike/types'\n\n")}// The settings of every page: https://vike.dev/config
|
|
1048
|
-
export default {
|
|
1049
|
-
${CONFIG_SETTINGS[rendering]}
|
|
1050
|
-
}${t(" satisfies Config")}
|
|
1051
|
-
`,
|
|
1052
|
-
PageShell: `import { StrictMode } from 'react'
|
|
1053
|
-
import { CacheProvider, styleCache } from '@soroush.tech/design-system/engine'
|
|
1054
|
-
${t("import type { PageContext } from 'vike/types'\n")}import { PageContextProvider } from './usePageContext'
|
|
1055
|
-
|
|
1056
|
-
/**
|
|
1057
|
-
* The page inside its +Layout. The Emotion cache is the design system's, so the styles the page
|
|
1058
|
-
* uses are found where it is drawn, and every component of the page can read its pageContext.
|
|
1059
|
-
*/
|
|
1060
|
-
export function PageShell({ pageContext }${t(": { readonly pageContext: PageContext }")}) {
|
|
1061
|
-
const { Page, config } = pageContext
|
|
1062
|
-
const { Layout } = config
|
|
1063
|
-
return (
|
|
1064
|
-
<StrictMode>
|
|
1065
|
-
<CacheProvider value={styleCache}>
|
|
1066
|
-
<PageContextProvider pageContext={pageContext}>
|
|
1067
|
-
{Layout ? (
|
|
1068
|
-
<Layout>
|
|
1069
|
-
<Page />
|
|
1070
|
-
</Layout>
|
|
1071
|
-
) : (
|
|
1072
|
-
<Page />
|
|
1073
|
-
)}
|
|
1074
|
-
</PageContextProvider>
|
|
1075
|
-
</CacheProvider>
|
|
1076
|
-
</StrictMode>
|
|
1077
|
-
)
|
|
1078
|
-
}
|
|
1079
|
-
`,
|
|
1080
|
-
spaOnRenderHtml: `import { escapeInject } from 'vike/server'
|
|
1081
|
-
${t("import type { OnRenderHtmlSync } from 'vike/types'\n")}
|
|
1082
|
-
/** The page's HTML shell, from the build: the browser renders the page in #root. */
|
|
1083
|
-
export const onRenderHtml${t(": OnRenderHtmlSync")} = () => {
|
|
1084
|
-
return escapeInject\`<!doctype html>
|
|
1085
|
-
<html lang="en">
|
|
1086
|
-
<head>
|
|
1087
|
-
<meta charset="UTF-8" />
|
|
1088
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1089
|
-
<title>${title}</title>
|
|
1090
|
-
</head>
|
|
1091
|
-
<body>
|
|
1092
|
-
<div id="root"></div>
|
|
1093
|
-
</body>
|
|
1094
|
-
</html>\`
|
|
1095
|
-
}
|
|
1096
|
-
`,
|
|
1097
|
-
spaOnRenderClient: `import { createRoot${t(", type Root")} } from 'react-dom/client'
|
|
1098
|
-
${t("import type { OnRenderClientSync } from 'vike/types'\n")}import { PageShell } from './PageShell'
|
|
1099
|
-
|
|
1100
|
-
let root${t(": Root | undefined")}
|
|
1101
|
-
|
|
1102
|
-
/** Draws the page in the browser, and each page the app moves to. */
|
|
1103
|
-
export const onRenderClient${t(": OnRenderClientSync")} = (pageContext) => {
|
|
1104
|
-
root ??= createRoot(document.getElementById('root')${t("!")})
|
|
1105
|
-
root.render(<PageShell pageContext={pageContext} />)
|
|
1106
|
-
}
|
|
1107
|
-
`,
|
|
1108
|
-
onRenderHtml: `import createEmotionServer from '@emotion/server/create-instance'
|
|
1109
|
-
import { renderToString } from 'react-dom/server'
|
|
1110
|
-
import { styleCache } from '@soroush.tech/design-system/engine'
|
|
1111
|
-
import { dangerouslySkipEscape, escapeInject } from 'vike/server'
|
|
1112
|
-
${t("import type { OnRenderHtmlSync } from 'vike/types'\n")}import { PageShell } from './PageShell'
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
* Renders the page to HTML - at build time, as the app is prerendered - with the styles it uses
|
|
1116
|
-
* in the head, so it is drawn styled before any script runs.
|
|
1117
|
-
*/
|
|
1118
|
-
export const onRenderHtml${t(": OnRenderHtmlSync")} = (pageContext) => {
|
|
1119
|
-
const { extractCriticalToChunks, constructStyleTagsFromChunks } = createEmotionServer(styleCache)
|
|
1120
|
-
const html = renderToString(<PageShell pageContext={pageContext} />)
|
|
1121
|
-
const styles = constructStyleTagsFromChunks(extractCriticalToChunks(html))
|
|
1122
|
-
return escapeInject\`<!doctype html>
|
|
1123
|
-
<html lang="en">
|
|
1124
|
-
<head>
|
|
1125
|
-
<meta charset="UTF-8" />
|
|
1126
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1127
|
-
<title>${title}</title>
|
|
1128
|
-
\${dangerouslySkipEscape(styles)}
|
|
1129
|
-
</head>
|
|
1130
|
-
<body>
|
|
1131
|
-
<div id="root">\${dangerouslySkipEscape(html)}</div>
|
|
1132
|
-
</body>
|
|
1133
|
-
</html>\`
|
|
1134
|
-
}
|
|
1135
|
-
`,
|
|
1136
|
-
onRenderClient: `import { createRoot, hydrateRoot${t(", type Root")} } from 'react-dom/client'
|
|
1137
|
-
${t("import type { OnRenderClientSync } from 'vike/types'\n")}import { PageShell } from './PageShell'
|
|
1138
|
-
|
|
1139
|
-
let root${t(": Root | undefined")}
|
|
1140
|
-
|
|
1141
|
-
/** Takes over the page the server drew, then draws each page the app moves to. */
|
|
1142
|
-
export const onRenderClient${t(": OnRenderClientSync")} = (pageContext) => {
|
|
1143
|
-
const page = <PageShell pageContext={pageContext} />
|
|
1144
|
-
const container = document.getElementById('root')${t("!")}
|
|
1145
|
-
if (pageContext.isHydration) {
|
|
1146
|
-
root = hydrateRoot(container, page)
|
|
1147
|
-
} else {
|
|
1148
|
-
root ??= createRoot(container)
|
|
1149
|
-
root.render(page)
|
|
1150
|
-
}
|
|
1151
|
-
}
|
|
1152
|
-
`,
|
|
1153
|
-
Layout: `${rendering === "ssg" ? `${t("import type { ReactNode } from 'react'\n")}import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1154
|
-
import { Link } from '@soroush.tech/design-system/Link'
|
|
1155
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1156
|
-
import { View } from '@soroush.tech/design-system/View'
|
|
1157
|
-
import { Providers } from '../theme/Providers'
|
|
1158
|
-
|
|
1159
|
-
/**
|
|
1160
|
-
* The frame every page renders in, inside the app's providers. A page has no JavaScript in the
|
|
1161
|
-
* browser, so it is drawn in the default scheme, which src/theme/Providers.${x} sets.
|
|
1162
|
-
*/
|
|
1163
|
-
export default function Layout({ children }${t(": { readonly children: ReactNode }")}) {
|
|
1164
|
-
return (
|
|
1165
|
-
<Providers>` : `import { useState${t(", type ReactNode")} } from 'react'
|
|
1166
|
-
import { Button } from '@soroush.tech/design-system/Button'
|
|
1167
|
-
import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1168
|
-
import { Link } from '@soroush.tech/design-system/Link'
|
|
1169
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1170
|
-
import { View } from '@soroush.tech/design-system/View'
|
|
1171
|
-
import { Providers } from '../theme/Providers'
|
|
1172
|
-
|
|
1173
|
-
/**
|
|
1174
|
-
* The frame every page renders in. The app's providers live here, in the app itself, so the
|
|
1175
|
-
* scheme it holds can switch the theme.
|
|
1176
|
-
*/
|
|
1177
|
-
export default function Layout({ children }${t(": { readonly children: ReactNode }")}) {
|
|
1178
|
-
const [scheme, setScheme] = useState${t("<'light' | 'dark'>")}('${scheme}')
|
|
1179
|
-
const otherScheme = scheme === 'light' ? 'dark' : 'light'
|
|
1180
|
-
return (
|
|
1181
|
-
<Providers scheme={scheme}>`}
|
|
1182
|
-
<Flex
|
|
1183
|
-
as="header"
|
|
1184
|
-
flexDirection="row"
|
|
1185
|
-
alignItems="center"
|
|
1186
|
-
justifyContent="space-between"
|
|
1187
|
-
gap={2}
|
|
1188
|
-
px={3}
|
|
1189
|
-
py={2}
|
|
1190
|
-
bg="paper"
|
|
1191
|
-
>
|
|
1192
|
-
<Typography variant="h6" as="span">
|
|
1193
|
-
${title}
|
|
1194
|
-
</Typography>
|
|
1195
|
-
<Flex as="nav" flexDirection="row" alignItems="center" gap={2}>
|
|
1196
|
-
<Link href="/" underline="hover">
|
|
1197
|
-
Home
|
|
1198
|
-
</Link>
|
|
1199
|
-
<Link href="/about" underline="hover">
|
|
1200
|
-
About
|
|
1201
|
-
</Link>
|
|
1202
|
-
${hasSampleData ? ITEMS_LINK : ""}${rendering === "ssg" ? "" : SCHEME_SWITCH} </Flex>
|
|
1203
|
-
</Flex>
|
|
1204
|
-
<View as="main" px={3} py={4}>
|
|
1205
|
-
{children}
|
|
1206
|
-
</View>
|
|
1207
|
-
</Providers>
|
|
1208
|
-
)
|
|
1209
|
-
}
|
|
1210
|
-
`,
|
|
1211
|
-
home: `import { Button } from '@soroush.tech/design-system/Button'
|
|
1212
|
-
import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1213
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1214
|
-
|
|
1215
|
-
export default function Page() {
|
|
1216
|
-
return (
|
|
1217
|
-
<Flex gap={2} alignItems="flex-start">
|
|
1218
|
-
<Typography variant="h2">${title}</Typography>
|
|
1219
|
-
<Typography color="secondary">
|
|
1220
|
-
A Vike app on the design system. Edit src/pages/index/+Page.${x}x, and make the themes your
|
|
1221
|
-
own in src/theme/themes.${x}.
|
|
1222
|
-
</Typography>
|
|
1223
|
-
<Flex flexDirection="row" gap={1}>
|
|
1224
|
-
<Button href="https://docs.soroush.tech">Components</Button>
|
|
1225
|
-
<Button href="https://vike.dev" variant="outlined">
|
|
1226
|
-
Vike
|
|
1227
|
-
</Button>
|
|
1228
|
-
</Flex>
|
|
1229
|
-
</Flex>
|
|
1230
|
-
)
|
|
1231
|
-
}
|
|
1232
|
-
`,
|
|
1233
|
-
about: `import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1234
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1235
|
-
|
|
1236
|
-
export default function Page() {
|
|
1237
|
-
return (
|
|
1238
|
-
<Flex gap={2}>
|
|
1239
|
-
<Typography variant="h2">About</Typography>
|
|
1240
|
-
<Typography color="secondary">
|
|
1241
|
-
${ABOUT_TEXT[rendering]}
|
|
1242
|
-
</Typography>
|
|
1243
|
-
</Flex>
|
|
1244
|
-
)
|
|
1245
|
-
}
|
|
1246
|
-
`,
|
|
1247
|
-
usePageContext: `import { createContext, useContext${t(", type ReactNode")} } from 'react'
|
|
1248
|
-
${t("import type { PageContext } from 'vike/types'\n")}
|
|
1249
|
-
const Context = createContext${t("<PageContext | undefined>")}(undefined)
|
|
1250
|
-
|
|
1251
|
-
/** Gives every component of the page its pageContext: https://vike.dev/pageContext */
|
|
1252
|
-
export function PageContextProvider({
|
|
1253
|
-
pageContext,
|
|
1254
|
-
children,
|
|
1255
|
-
}${t(`: {
|
|
1256
|
-
readonly pageContext: PageContext
|
|
1257
|
-
readonly children: ReactNode
|
|
1258
|
-
}`)}) {
|
|
1259
|
-
return <Context.Provider value={pageContext}>{children}</Context.Provider>
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
/** The pageContext of the page on screen: its URL, its route's parameters, its data. */
|
|
1263
|
-
export function usePageContext() {
|
|
1264
|
-
const pageContext = useContext(Context)
|
|
1265
|
-
if (!pageContext) throw new Error('usePageContext runs only inside a page.')
|
|
1266
|
-
return pageContext
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
/** What the page's +data returned: https://vike.dev/data */
|
|
1270
|
-
export function useData${t("<Data>")}() {
|
|
1271
|
-
return usePageContext().data${t(" as Data")}
|
|
1272
|
-
}
|
|
1273
|
-
`,
|
|
1274
|
-
error: `import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1275
|
-
import { Link } from '@soroush.tech/design-system/Link'
|
|
1276
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1277
|
-
|
|
1278
|
-
/** Shown for a page that does not exist, and when a page fails to render. */
|
|
1279
|
-
export default function Page() {
|
|
1280
|
-
return (
|
|
1281
|
-
<Flex gap={2} alignItems="flex-start">
|
|
1282
|
-
<Typography variant="h2">Page not found</Typography>
|
|
1283
|
-
<Typography color="secondary">This page does not exist, or it could not be shown.</Typography>
|
|
1284
|
-
<Link href="/">Back home</Link>
|
|
1285
|
-
</Flex>
|
|
1286
|
-
)
|
|
1287
|
-
}
|
|
1288
|
-
`
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
/**
|
|
1292
|
-
* The sample data pages: a list of items and a page for each, which read `src/data/items` in their
|
|
1293
|
-
* +data hooks, at build time.
|
|
1294
|
-
*/
|
|
1295
|
-
function createSampleDataFiles({ isTypeScript }) {
|
|
1296
|
-
const t = (typeScriptOnly) => isTypeScript ? typeScriptOnly : "";
|
|
1297
|
-
const x = isTypeScript ? "ts" : "js";
|
|
1298
|
-
const dataType = t("\nexport type Data = ReturnType<typeof data>\n");
|
|
1299
|
-
const items = `${t(`/** One sample item. */
|
|
1300
|
-
export interface Item {
|
|
1301
|
-
id: string
|
|
1302
|
-
title: string
|
|
1303
|
-
summary: string
|
|
1304
|
-
status: 'todo' | 'doing' | 'done'
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
`)}/**
|
|
1308
|
-
* Sample data, so the items pages have something to show: each page's +data reads it at build
|
|
1309
|
-
* time. Make the +data hooks fetch your own data instead, and remove this file.
|
|
1310
|
-
*/
|
|
1311
|
-
export const items${t(": readonly Item[]")} = [
|
|
1312
|
-
{
|
|
1313
|
-
id: 'theme',
|
|
1314
|
-
title: 'Make the theme your own',
|
|
1315
|
-
summary: 'Change the colors and fonts of both themes in src/theme/themes.${x}.',
|
|
1316
|
-
status: 'doing',
|
|
1317
|
-
},
|
|
1318
|
-
{
|
|
1319
|
-
id: 'fonts',
|
|
1320
|
-
title: 'Load the fonts',
|
|
1321
|
-
summary: 'The theme names Space Grotesk and JetBrains Mono, and does not load them.',
|
|
1322
|
-
status: 'todo',
|
|
1323
|
-
},
|
|
1324
|
-
{
|
|
1325
|
-
id: 'pages',
|
|
1326
|
-
title: 'Add a page',
|
|
1327
|
-
summary: 'A folder in src/pages with a +Page in it is a new route.',
|
|
1328
|
-
status: 'todo',
|
|
1329
|
-
},
|
|
1330
|
-
{
|
|
1331
|
-
id: 'data',
|
|
1332
|
-
title: 'Read your own data',
|
|
1333
|
-
summary: 'Each +data here reads this file. Make it fetch from your API, at build time.',
|
|
1334
|
-
status: 'todo',
|
|
1335
|
-
},
|
|
1336
|
-
{
|
|
1337
|
-
id: 'build',
|
|
1338
|
-
title: 'Build it',
|
|
1339
|
-
summary: 'The build prerenders every page, these items among them, to HTML with its styles.',
|
|
1340
|
-
status: 'done',
|
|
1341
|
-
},
|
|
1342
|
-
{
|
|
1343
|
-
id: 'deploy',
|
|
1344
|
-
title: 'Deploy it',
|
|
1345
|
-
summary: 'The build is static files in dist/client, which any static host serves.',
|
|
1346
|
-
status: 'todo',
|
|
1347
|
-
},
|
|
1348
|
-
]
|
|
1349
|
-
`;
|
|
1350
|
-
const statusChip = `import { Chip } from '@soroush.tech/design-system/Chip'
|
|
1351
|
-
${t("import type { Item } from '../../data/items'\n")}
|
|
1352
|
-
const COLORS = { todo: 'default', doing: 'primary', done: 'success' }${t(" as const")}
|
|
1353
|
-
|
|
1354
|
-
/** An item's status, in its palette color. */
|
|
1355
|
-
export function StatusChip({ status }${t(": { readonly status: Item['status'] }")}) {
|
|
1356
|
-
return <Chip label={status} size="sm" variant="outlined" color={COLORS[status]} />
|
|
1357
|
-
}
|
|
1358
|
-
`;
|
|
1359
|
-
const listData = `import { items } from '../../data/items'
|
|
1360
|
-
|
|
1361
|
-
/**
|
|
1362
|
-
* The list page's data: what it shows of each item. It runs at build time, as the page is
|
|
1363
|
-
* prerendered. https://vike.dev/data
|
|
1364
|
-
*/
|
|
1365
|
-
export function data() {
|
|
1366
|
-
return items.map(({ id, title, status }) => ({ id, title, status }))
|
|
1367
|
-
}
|
|
1368
|
-
${dataType}`;
|
|
1369
|
-
const listPage = `import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1370
|
-
import { Link } from '@soroush.tech/design-system/Link'
|
|
1371
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1372
|
-
import { useData } from '../usePageContext'
|
|
1373
|
-
${t("import type { Data } from './+data'\n")}import { StatusChip } from './StatusChip'
|
|
1374
|
-
|
|
1375
|
-
export default function Page() {
|
|
1376
|
-
const items = useData${t("<Data>")}()
|
|
1377
|
-
return (
|
|
1378
|
-
<Flex gap={2}>
|
|
1379
|
-
<Typography variant="h2">Items</Typography>
|
|
1380
|
-
<Typography color="secondary">
|
|
1381
|
-
Sample data from src/data/items.${x}, which this page's +data reads at build time.
|
|
1382
|
-
</Typography>
|
|
1383
|
-
<Flex gap={1}>
|
|
1384
|
-
{items.map((item) => (
|
|
1385
|
-
<Flex key={item.id} flexDirection="row" alignItems="center" gap={2}>
|
|
1386
|
-
<Link href={\`/items/\${item.id}\`}>{item.title}</Link>
|
|
1387
|
-
<StatusChip status={item.status} />
|
|
1388
|
-
</Flex>
|
|
1389
|
-
))}
|
|
1390
|
-
</Flex>
|
|
1391
|
-
</Flex>
|
|
1392
|
-
)
|
|
1393
|
-
}
|
|
1394
|
-
`;
|
|
1395
|
-
const itemData = `import { render } from 'vike/abort'
|
|
1396
|
-
${t("import type { PageContextServer } from 'vike/types'\n")}import { items } from '../../../data/items'
|
|
1397
|
-
|
|
1398
|
-
/**
|
|
1399
|
-
* One item's data, by the id in the URL, or the 404 page for an id with no item. It runs at build
|
|
1400
|
-
* time, for each URL +onBeforePrerenderStart lists. https://vike.dev/data
|
|
1401
|
-
*/
|
|
1402
|
-
export function data(pageContext${t(": PageContextServer")}) {
|
|
1403
|
-
const item = items.find(({ id }) => id === pageContext.routeParams.id)
|
|
1404
|
-
if (!item) throw render(404)
|
|
1405
|
-
return item
|
|
1406
|
-
}
|
|
1407
|
-
${dataType}`;
|
|
1408
|
-
const itemPrerender = `import { items } from '../../../data/items'
|
|
1409
|
-
|
|
1410
|
-
/** The URLs of this route the build prerenders: one per item. https://vike.dev/onBeforePrerenderStart */
|
|
1411
|
-
export function onBeforePrerenderStart() {
|
|
1412
|
-
return items.map(({ id }) => \`/items/\${id}\`)
|
|
1413
|
-
}
|
|
1414
|
-
`;
|
|
1415
|
-
const itemPage = `import { Flex } from '@soroush.tech/design-system/Flex'
|
|
1416
|
-
import { Link } from '@soroush.tech/design-system/Link'
|
|
1417
|
-
import { Typography } from '@soroush.tech/design-system/Typography'
|
|
1418
|
-
import { useData } from '../../usePageContext'
|
|
1419
|
-
import { StatusChip } from '../StatusChip'
|
|
1420
|
-
${t("import type { Data } from './+data'\n")}
|
|
1421
|
-
export default function Page() {
|
|
1422
|
-
const item = useData${t("<Data>")}()
|
|
1423
|
-
return (
|
|
1424
|
-
<Flex gap={2} alignItems="flex-start">
|
|
1425
|
-
<Typography variant="h2">{item.title}</Typography>
|
|
1426
|
-
<StatusChip status={item.status} />
|
|
1427
|
-
<Typography color="secondary">{item.summary}</Typography>
|
|
1428
|
-
<Link href="/items">All items</Link>
|
|
1429
|
-
</Flex>
|
|
1430
|
-
)
|
|
1431
|
-
}
|
|
1432
|
-
`;
|
|
1433
|
-
return [
|
|
1434
|
-
{
|
|
1435
|
-
path: `src/data/items.${x}`,
|
|
1436
|
-
content: items
|
|
1437
|
-
},
|
|
1438
|
-
{
|
|
1439
|
-
path: `src/pages/items/StatusChip.${x}x`,
|
|
1440
|
-
content: statusChip
|
|
1441
|
-
},
|
|
1442
|
-
{
|
|
1443
|
-
path: `src/pages/items/+data.${x}`,
|
|
1444
|
-
content: listData
|
|
1445
|
-
},
|
|
1446
|
-
{
|
|
1447
|
-
path: `src/pages/items/+Page.${x}x`,
|
|
1448
|
-
content: listPage
|
|
1449
|
-
},
|
|
1450
|
-
{
|
|
1451
|
-
path: `src/pages/items/@id/+data.${x}`,
|
|
1452
|
-
content: itemData
|
|
1453
|
-
},
|
|
1454
|
-
{
|
|
1455
|
-
path: `src/pages/items/@id/+onBeforePrerenderStart.${x}`,
|
|
1456
|
-
content: itemPrerender
|
|
1457
|
-
},
|
|
1458
|
-
{
|
|
1459
|
-
path: `src/pages/items/@id/+Page.${x}x`,
|
|
1460
|
-
content: itemPage
|
|
1461
|
-
}
|
|
1462
|
-
];
|
|
1463
|
-
}
|
|
1464
|
-
/** How the README says each rendering works, and which files render the pages. */
|
|
1465
|
-
const README_RENDERING = {
|
|
1466
|
-
isomorphic: {
|
|
1467
|
-
summary: "prerendered at build time with its styles in the HTML, then moving between pages with no reload.",
|
|
1468
|
-
renderers: "`+onRenderHtml` and `+onRenderClient` render the pages, with the styles each page uses in its HTML."
|
|
1469
|
-
},
|
|
1470
|
-
spa: {
|
|
1471
|
-
summary: "a single-page app: each page is an HTML shell from the build, rendered in the browser, which moves between pages with no reload.",
|
|
1472
|
-
renderers: "`+onRenderHtml` writes the HTML shell of each page, and `+onRenderClient` renders the page in it."
|
|
1473
|
-
},
|
|
1474
|
-
ssg: {
|
|
1475
|
-
summary: "every page prerendered to HTML at build time, with its styles, and no JavaScript in the browser.",
|
|
1476
|
-
renderers: "`+onRenderHtml` renders the pages to HTML, with the styles each page uses."
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
1479
|
-
function createReadme({ title, isTypeScript, rendering, hasSampleData }) {
|
|
1480
|
-
const x = isTypeScript ? "ts" : "js";
|
|
1481
|
-
const { summary, renderers } = README_RENDERING[rendering];
|
|
1482
|
-
return `# ${title}
|
|
1483
|
-
|
|
1484
|
-
A [Vike](https://vike.dev) app on the [@soroush.tech design system](https://docs.soroush.tech):
|
|
1485
|
-
${summary}
|
|
1486
|
-
|
|
1487
|
-
- \`npm run dev\` starts it, \`npm run build\` builds it, and \`npm run preview\` serves the build.
|
|
1488
|
-
- \`src/pages/\` holds the pages: a folder per route, each with its \`+Page\`.
|
|
1489
|
-
- \`src/pages/+Layout.${x}x\` is the frame every page renders in, inside the app's providers.
|
|
1490
|
-
- \`src/theme/themes.${x}\` holds the light and the dark theme: make them your own.
|
|
1491
|
-
- In \`src/pages/\`, ${renderers}
|
|
1492
|
-
${hasSampleData ? `- \`src/pages/items/\` lists the sample items of \`src/data/items.${x}\`, with a page for each.
|
|
1493
|
-
Their \`+data\` hooks read the data at build time: make them fetch your own.
|
|
1494
|
-
` : ""}
|
|
1495
|
-
Fonts: the theme names Space Grotesk and JetBrains Mono, and does not load them. See
|
|
1496
|
-
https://docs.soroush.tech/design-system/getting-started/installation/#fonts
|
|
1497
|
-
`;
|
|
1498
|
-
}
|
|
1499
1316
|
/** The files of the Vike app `facts` describe. */
|
|
1500
1317
|
function createFiles(facts) {
|
|
1501
|
-
const { isTypeScript,
|
|
1318
|
+
const { isTypeScript, scheme } = facts;
|
|
1502
1319
|
const x = isTypeScript ? "ts" : "js";
|
|
1503
|
-
const sources = createSources(facts);
|
|
1504
|
-
const isSpa = rendering === "spa";
|
|
1505
|
-
const onRenderClient = rendering === "ssg" ? void 0 : isSpa ? sources.spaOnRenderClient : sources.onRenderClient;
|
|
1506
1320
|
return [
|
|
1507
1321
|
{
|
|
1508
1322
|
path: "package.json",
|
|
1509
1323
|
content: createPackageJson(facts)
|
|
1510
1324
|
},
|
|
1511
|
-
{
|
|
1512
|
-
path: `vite.config.${x}`,
|
|
1513
|
-
content: VITE_CONFIG
|
|
1514
|
-
},
|
|
1515
|
-
...isTypeScript ? [{
|
|
1516
|
-
path: "tsconfig.json",
|
|
1517
|
-
content: TSCONFIG
|
|
1518
|
-
}] : [],
|
|
1519
|
-
{
|
|
1520
|
-
path: ".gitignore",
|
|
1521
|
-
content: GITIGNORE
|
|
1522
|
-
},
|
|
1523
|
-
{
|
|
1524
|
-
path: "README.md",
|
|
1525
|
-
content: createReadme(facts)
|
|
1526
|
-
},
|
|
1527
|
-
...isTypeScript ? [{
|
|
1528
|
-
path: "src/vike.d.ts",
|
|
1529
|
-
content: VIKE_TYPES
|
|
1530
|
-
}] : [],
|
|
1531
1325
|
{
|
|
1532
1326
|
path: `src/theme/themes.${x}`,
|
|
1533
1327
|
content: createThemesSource({ isTypeScript })
|
|
@@ -1540,58 +1334,111 @@ function createFiles(facts) {
|
|
|
1540
1334
|
themesImport: "./themes"
|
|
1541
1335
|
})
|
|
1542
1336
|
},
|
|
1543
|
-
|
|
1544
|
-
path: `src/pages/+config.${x}`,
|
|
1545
|
-
content: sources.config
|
|
1546
|
-
},
|
|
1547
|
-
{
|
|
1548
|
-
path: `src/pages/PageShell.${x}x`,
|
|
1549
|
-
content: sources.PageShell
|
|
1550
|
-
},
|
|
1551
|
-
{
|
|
1552
|
-
path: `src/pages/usePageContext.${x}x`,
|
|
1553
|
-
content: sources.usePageContext
|
|
1554
|
-
},
|
|
1555
|
-
{
|
|
1556
|
-
path: `src/pages/+onRenderHtml.${x}x`,
|
|
1557
|
-
content: isSpa ? sources.spaOnRenderHtml : sources.onRenderHtml
|
|
1558
|
-
},
|
|
1559
|
-
...onRenderClient ? [{
|
|
1560
|
-
path: `src/pages/+onRenderClient.${x}x`,
|
|
1561
|
-
content: onRenderClient
|
|
1562
|
-
}] : [],
|
|
1563
|
-
{
|
|
1564
|
-
path: `src/pages/+Layout.${x}x`,
|
|
1565
|
-
content: sources.Layout
|
|
1566
|
-
},
|
|
1567
|
-
{
|
|
1568
|
-
path: `src/pages/index/+Page.${x}x`,
|
|
1569
|
-
content: sources.home
|
|
1570
|
-
},
|
|
1571
|
-
{
|
|
1572
|
-
path: `src/pages/about/+Page.${x}x`,
|
|
1573
|
-
content: sources.about
|
|
1574
|
-
},
|
|
1575
|
-
{
|
|
1576
|
-
path: `src/pages/_error/+Page.${x}x`,
|
|
1577
|
-
content: sources.error
|
|
1578
|
-
},
|
|
1579
|
-
...facts.hasSampleData ? createSampleDataFiles(facts) : []
|
|
1337
|
+
...createTemplateFiles("vike", facts)
|
|
1580
1338
|
];
|
|
1581
1339
|
}
|
|
1582
1340
|
const vikeStarter = {
|
|
1583
1341
|
title: "Vike",
|
|
1342
|
+
label: "Vike (recommended): React pages, rendered as you pick",
|
|
1343
|
+
renderings: [
|
|
1344
|
+
"isomorphic",
|
|
1345
|
+
"ssr",
|
|
1346
|
+
"spa",
|
|
1347
|
+
"ssg"
|
|
1348
|
+
],
|
|
1349
|
+
hasLibraries: true,
|
|
1584
1350
|
createFiles
|
|
1585
1351
|
};
|
|
1586
1352
|
// src/create/starters.ts
|
|
1587
1353
|
/** The renderings, in the order create offers them. The first is the default. */
|
|
1588
1354
|
const RENDERINGS = [
|
|
1589
1355
|
"isomorphic",
|
|
1356
|
+
"ssr",
|
|
1590
1357
|
"spa",
|
|
1591
1358
|
"ssg"
|
|
1592
1359
|
];
|
|
1593
1360
|
/** The starters, by the name `--framework` takes. The first is the default. */
|
|
1594
|
-
const STARTERS = {
|
|
1361
|
+
const STARTERS = {
|
|
1362
|
+
vike: vikeStarter,
|
|
1363
|
+
astro: astroStarter
|
|
1364
|
+
};
|
|
1365
|
+
// src/create/workspace.ts
|
|
1366
|
+
/** The layouts, in the order create offers them. The first is the default. */
|
|
1367
|
+
const LAYOUTS = ["workspace", "standalone"];
|
|
1368
|
+
/** Where a workspace keeps the app, from its root. */
|
|
1369
|
+
const APP_FOLDER = "apps/web";
|
|
1370
|
+
/** The package name of the app in the workspace named `packageName`. */
|
|
1371
|
+
const toAppPackageName = (packageName) => `@${packageName}/web`;
|
|
1372
|
+
/** The command that runs `script` of the app's package, from the workspace's root. */
|
|
1373
|
+
function runInApp(packageManager, app, script) {
|
|
1374
|
+
switch (packageManager) {
|
|
1375
|
+
case "npm": return `npm run ${script} --workspace=${app}`;
|
|
1376
|
+
case "pnpm": return `pnpm --filter ${app} ${script}`;
|
|
1377
|
+
case "yarn": return `yarn workspace ${app} ${script}`;
|
|
1378
|
+
case "bun": return `bun run --filter ${app} ${script}`;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const WORKSPACES = ["apps/*", "services/*"];
|
|
1382
|
+
const GITIGNORE = `node_modules/
|
|
1383
|
+
*.log
|
|
1384
|
+
.DS_Store
|
|
1385
|
+
`;
|
|
1386
|
+
/** The names of the scripts in the app's package.json, which the root runs by the same names. */
|
|
1387
|
+
function readAppScripts(appFiles) {
|
|
1388
|
+
const packageJson = appFiles.find((file) => file.path === "package.json");
|
|
1389
|
+
return Object.keys(JSON.parse(packageJson?.content ?? "{}").scripts ?? {});
|
|
1390
|
+
}
|
|
1391
|
+
function createRootFiles(facts, scripts) {
|
|
1392
|
+
const { packageName, title, packageManager } = facts;
|
|
1393
|
+
const app = toAppPackageName(packageName);
|
|
1394
|
+
const isPnpm = packageManager === "pnpm";
|
|
1395
|
+
const packageJson = {
|
|
1396
|
+
name: packageName,
|
|
1397
|
+
private: true,
|
|
1398
|
+
...isPnpm ? {} : { workspaces: WORKSPACES },
|
|
1399
|
+
scripts: Object.fromEntries(scripts.map((script) => [script, runInApp(packageManager, app, script)]))
|
|
1400
|
+
};
|
|
1401
|
+
const run = (script) => packageManager === "npm" || packageManager === "bun" ? `${packageManager} run ${script}` : `${packageManager} ${script}`;
|
|
1402
|
+
return [
|
|
1403
|
+
{
|
|
1404
|
+
path: "package.json",
|
|
1405
|
+
content: `${JSON.stringify(packageJson, null, 2)}\n`
|
|
1406
|
+
},
|
|
1407
|
+
...isPnpm ? [{
|
|
1408
|
+
path: "pnpm-workspace.yaml",
|
|
1409
|
+
content: `packages:\n${WORKSPACES.map((glob) => ` - ${glob}\n`).join("")}`
|
|
1410
|
+
}] : [],
|
|
1411
|
+
{
|
|
1412
|
+
path: ".gitignore",
|
|
1413
|
+
content: GITIGNORE
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
path: "README.md",
|
|
1417
|
+
content: `# ${title}
|
|
1418
|
+
|
|
1419
|
+
A workspace: each app and service is a package of its own, installed together from here.
|
|
1420
|
+
|
|
1421
|
+
- \`${APP_FOLDER}/\` is the web app, \`${app}\`: its README says how it is built.
|
|
1422
|
+
- \`services/\` is for back-end services, such as an API: add one as a folder with its own
|
|
1423
|
+
\`package.json\`.
|
|
1424
|
+
|
|
1425
|
+
From here, \`${run("dev")}\` starts the web app, \`${run("build")}\` builds it, and \`${run("preview")}\`
|
|
1426
|
+
serves the build.
|
|
1427
|
+
`
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
path: "services/.gitkeep",
|
|
1431
|
+
content: ""
|
|
1432
|
+
}
|
|
1433
|
+
];
|
|
1434
|
+
}
|
|
1435
|
+
/** The files of a workspace holding the app whose files are `appFiles`, in `apps/web`. */
|
|
1436
|
+
function createWorkspaceFiles(appFiles, facts) {
|
|
1437
|
+
return [...createRootFiles(facts, readAppScripts(appFiles)), ...appFiles.map((file) => ({
|
|
1438
|
+
...file,
|
|
1439
|
+
path: `${APP_FOLDER}/${file.path}`
|
|
1440
|
+
}))];
|
|
1441
|
+
}
|
|
1595
1442
|
// src/create/create.ts
|
|
1596
1443
|
const DEFAULT_NAME = "my-app";
|
|
1597
1444
|
const APP_NAME = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
|
|
@@ -1681,6 +1528,18 @@ function resolvePackageManager(name, detected, io) {
|
|
|
1681
1528
|
isYarnBerry: name === "yarn" && Number.parseInt(stdout, 10) >= 2
|
|
1682
1529
|
};
|
|
1683
1530
|
}
|
|
1531
|
+
/** What the repository question says of each layout. */
|
|
1532
|
+
const LAYOUT_LABELS = {
|
|
1533
|
+
workspace: "Workspace (recommended): the app in apps/web, with room for more apps and services",
|
|
1534
|
+
standalone: "Standalone: the app alone"
|
|
1535
|
+
};
|
|
1536
|
+
async function askLayout(io) {
|
|
1537
|
+
const choices = LAYOUTS.map((value) => ({
|
|
1538
|
+
value,
|
|
1539
|
+
label: LAYOUT_LABELS[value]
|
|
1540
|
+
}));
|
|
1541
|
+
return await io.select("Repository", choices);
|
|
1542
|
+
}
|
|
1684
1543
|
async function askTitle(io, name) {
|
|
1685
1544
|
return (await io.ask(`App title? (${name}) `)).trim() || name;
|
|
1686
1545
|
}
|
|
@@ -1690,16 +1549,49 @@ async function askName(io) {
|
|
|
1690
1549
|
/** What the rendering question says of each one. */
|
|
1691
1550
|
const RENDERING_LABELS = {
|
|
1692
1551
|
isomorphic: "Isomorphic (recommended): HTML from the build, then no reload",
|
|
1552
|
+
ssr: "SSR: HTML from a server, on each request, then no reload",
|
|
1693
1553
|
spa: "SPA: rendered in the browser",
|
|
1694
1554
|
ssg: "SSG: HTML only, no JavaScript"
|
|
1695
1555
|
};
|
|
1696
|
-
async function askRendering(io) {
|
|
1697
|
-
const choices =
|
|
1556
|
+
async function askRendering(io, renderings) {
|
|
1557
|
+
const choices = renderings.map((value) => ({
|
|
1698
1558
|
value,
|
|
1699
1559
|
label: RENDERING_LABELS[value]
|
|
1700
1560
|
}));
|
|
1701
1561
|
return await io.select("Rendering", choices);
|
|
1702
1562
|
}
|
|
1563
|
+
/** Asks for the framework, of the ones `names` lists. */
|
|
1564
|
+
async function askFramework(io, starters, names) {
|
|
1565
|
+
const choices = names.map((value) => ({
|
|
1566
|
+
value,
|
|
1567
|
+
label: starters[value].label
|
|
1568
|
+
}));
|
|
1569
|
+
return io.select("Framework", choices);
|
|
1570
|
+
}
|
|
1571
|
+
/** The choices of one job's question: the libraries of `group`, or those of none. */
|
|
1572
|
+
const getLibraryChoices = (group) => LIBRARIES.filter((library) => library.group === group).map(({ name, label }) => ({
|
|
1573
|
+
value: name,
|
|
1574
|
+
label
|
|
1575
|
+
}));
|
|
1576
|
+
const NO_LIBRARY = {
|
|
1577
|
+
value: "none",
|
|
1578
|
+
label: "None"
|
|
1579
|
+
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Asks for the libraries by job: one that fetches data, one that holds state - each of them or
|
|
1582
|
+
* none - then the others, toggled. Returns them in the order create offers them.
|
|
1583
|
+
*/
|
|
1584
|
+
async function askLibraries(io) {
|
|
1585
|
+
const data = await io.select("Data fetching", [NO_LIBRARY, ...getLibraryChoices("data")]);
|
|
1586
|
+
const state = await io.select("State management", [NO_LIBRARY, ...getLibraryChoices("state")]);
|
|
1587
|
+
const more = await io.selectMany("More", getLibraryChoices(void 0));
|
|
1588
|
+
const picked = /* @__PURE__ */ new Set([
|
|
1589
|
+
data,
|
|
1590
|
+
state,
|
|
1591
|
+
...more
|
|
1592
|
+
]);
|
|
1593
|
+
return LIBRARY_NAMES.filter((name) => picked.has(name));
|
|
1594
|
+
}
|
|
1703
1595
|
async function askSampleData(io) {
|
|
1704
1596
|
return await io.select("Add sample data pages?", YES_OR_NO, 1) === "yes";
|
|
1705
1597
|
}
|
|
@@ -1765,13 +1657,14 @@ function writeAndInstall({ name, target, wasMissing, plan, packageManager }, opt
|
|
|
1765
1657
|
async function runCreate(options, io, designSystem, { starters = STARTERS, fileSystem = nodeFileSystem, userAgent = process.env.npm_config_user_agent } = {}) {
|
|
1766
1658
|
const isPreviewOnly = options.isDryRun || !io.isInteractive && !options.isConfirmed;
|
|
1767
1659
|
const canAsk = !isPreviewOnly && !options.isConfirmed;
|
|
1768
|
-
const
|
|
1769
|
-
const
|
|
1770
|
-
if (!
|
|
1771
|
-
const names =
|
|
1772
|
-
io.write(`create has no starter for ${
|
|
1660
|
+
const frameworks = Object.keys(starters);
|
|
1661
|
+
const given = options.framework;
|
|
1662
|
+
if (frameworks.length === 0 || given !== void 0 && !Object.hasOwn(starters, given)) {
|
|
1663
|
+
const names = frameworks.join(", ") || "none yet";
|
|
1664
|
+
io.write(`create has no starter for ${given ?? "any framework"}. It has: ${names}.\n`);
|
|
1773
1665
|
return 1;
|
|
1774
1666
|
}
|
|
1667
|
+
const pool = given === void 0 ? frameworks : [given];
|
|
1775
1668
|
const name = options.name ?? (canAsk ? await askName(io) : DEFAULT_NAME);
|
|
1776
1669
|
const nameRefusal = findNameRefusal(name);
|
|
1777
1670
|
if (nameRefusal) {
|
|
@@ -1797,20 +1690,42 @@ async function runCreate(options, io, designSystem, { starters = STARTERS, fileS
|
|
|
1797
1690
|
io.write(`${packageManager.refusal}\n`);
|
|
1798
1691
|
return 1;
|
|
1799
1692
|
}
|
|
1800
|
-
const
|
|
1693
|
+
const isWorkspace = (options.layout ?? (canAsk ? await askLayout(io) : LAYOUTS[0])) === "workspace";
|
|
1694
|
+
const offered = RENDERINGS.filter((rendering) => pool.some((framework) => starters[framework].renderings.includes(rendering)));
|
|
1695
|
+
if (options.rendering !== void 0 && !offered.includes(options.rendering)) {
|
|
1696
|
+
const titles = pool.map((framework) => starters[framework].title).join(" or ");
|
|
1697
|
+
io.write(`${titles} does not render ${options.rendering}: it renders ${offered.join(" or ")}.\n`);
|
|
1698
|
+
return 1;
|
|
1699
|
+
}
|
|
1700
|
+
const rendering = options.rendering ?? (canAsk && offered.length > 1 ? await askRendering(io, offered) : offered[0]);
|
|
1701
|
+
const candidates = pool.filter((framework) => starters[framework].renderings.includes(rendering));
|
|
1702
|
+
const starter = starters[canAsk && candidates.length > 1 ? await askFramework(io, starters, candidates) : candidates[0]];
|
|
1703
|
+
const libraryRefusal = !options.libraries?.length ? void 0 : rendering === "ssg" ? "An SSG app has no JavaScript in the browser, so it takes no library: leave out --with." : starter.hasLibraries ? findLibraryConflict(options.libraries) : `${starter.title} takes no library yet: leave out --with.`;
|
|
1704
|
+
if (libraryRefusal) {
|
|
1705
|
+
io.write(`${libraryRefusal}\n`);
|
|
1706
|
+
return 1;
|
|
1707
|
+
}
|
|
1708
|
+
const takesLibraries = starter.hasLibraries && rendering !== "ssg";
|
|
1709
|
+
const libraries = options.libraries ?? (canAsk && takesLibraries ? await askLibraries(io) : []);
|
|
1801
1710
|
const scheme = options.scheme ?? (canAsk ? await askScheme(io) : "light");
|
|
1802
1711
|
const hasSampleData = options.hasSampleData ?? (canAsk ? await askSampleData(io) : false);
|
|
1712
|
+
const appFiles = starter.createFiles({
|
|
1713
|
+
name,
|
|
1714
|
+
packageName: isWorkspace ? toAppPackageName(packageName) : packageName,
|
|
1715
|
+
title,
|
|
1716
|
+
isTypeScript,
|
|
1717
|
+
rendering,
|
|
1718
|
+
libraries,
|
|
1719
|
+
scheme,
|
|
1720
|
+
hasSampleData,
|
|
1721
|
+
version: designSystem.version
|
|
1722
|
+
});
|
|
1803
1723
|
const plan = {
|
|
1804
|
-
creates:
|
|
1805
|
-
name,
|
|
1724
|
+
creates: isWorkspace ? createWorkspaceFiles(appFiles, {
|
|
1806
1725
|
packageName,
|
|
1807
1726
|
title,
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
scheme,
|
|
1811
|
-
hasSampleData,
|
|
1812
|
-
version: designSystem.version
|
|
1813
|
-
}),
|
|
1727
|
+
packageManager: packageManager.name
|
|
1728
|
+
}) : appFiles,
|
|
1814
1729
|
edits: [],
|
|
1815
1730
|
skips: [],
|
|
1816
1731
|
manual: [],
|
|
@@ -1819,7 +1734,7 @@ async function runCreate(options, io, designSystem, { starters = STARTERS, fileS
|
|
|
1819
1734
|
const language = isTypeScript ? "TypeScript" : "JavaScript";
|
|
1820
1735
|
const packageNote = packageName === name ? "" : ` (package ${packageName})`;
|
|
1821
1736
|
const renderingName = rendering === "isomorphic" ? rendering : rendering.toUpperCase();
|
|
1822
|
-
io.write(`create will make ${name}${packageNote}, a ${starter.title} app in ${language} (${renderingName}), in ./${name}:\n\n`);
|
|
1737
|
+
io.write(`create will make ${name}${packageNote}, ${/^[AEIOU]/.test(starter.title) ? "an" : "a"} ${starter.title} app in ${language} (${renderingName}), ${isWorkspace ? "in a workspace, " : ""}in ./${name}:\n\n`);
|
|
1823
1738
|
io.write(`${formatPlan(plan)}\n`);
|
|
1824
1739
|
if (!await isApproved(options, isPreviewOnly, io)) return 0;
|
|
1825
1740
|
return writeAndInstall({
|
|
@@ -1916,14 +1831,17 @@ an empty one. Its package.json takes the name in lowercase: testApp is test-app.
|
|
|
1916
1831
|
the options do not say, shows every file first, and writes nothing until you say yes.
|
|
1917
1832
|
|
|
1918
1833
|
Options:
|
|
1919
|
-
-y, --yes create without asking: TypeScript, light, no sample data
|
|
1834
|
+
-y, --yes create without asking: TypeScript, a workspace, light, no sample data
|
|
1920
1835
|
--dry-run show the files and exit
|
|
1921
1836
|
--title <text> what the app's pages call it: the name when not given
|
|
1922
1837
|
--framework <name> the app's framework: ${[`${defaultFramework} (the default)`, ...otherFrameworks].join(", ")}
|
|
1923
1838
|
--ts, --js TypeScript (the default) or JavaScript
|
|
1924
1839
|
--pm <name> the package manager: npm, pnpm, yarn or bun; the one that ran create
|
|
1925
1840
|
when not given
|
|
1926
|
-
--
|
|
1841
|
+
--layout <name> workspace (the default): the app in apps/web, with room for more
|
|
1842
|
+
apps and services; or standalone: the app alone
|
|
1843
|
+
--render <name> how pages render: isomorphic (the default), ssr, spa or ssg
|
|
1844
|
+
--with <names> the libraries to add, by comma: ${LIBRARY_NAMES.join(", ")}
|
|
1927
1845
|
--scheme <name> the default color scheme: light (the default) or dark
|
|
1928
1846
|
--sample-data add a list of sample items, and a page for each
|
|
1929
1847
|
--no-git do not run git init
|
|
@@ -1953,7 +1871,9 @@ const OPTIONS = {
|
|
|
1953
1871
|
ts: { type: "boolean" },
|
|
1954
1872
|
js: { type: "boolean" },
|
|
1955
1873
|
pm: { type: "string" },
|
|
1874
|
+
layout: { type: "string" },
|
|
1956
1875
|
render: { type: "string" },
|
|
1876
|
+
with: { type: "string" },
|
|
1957
1877
|
"sample-data": { type: "boolean" },
|
|
1958
1878
|
"no-git": { type: "boolean" }
|
|
1959
1879
|
};
|
|
@@ -1966,7 +1886,9 @@ const OWN_OPTIONS = {
|
|
|
1966
1886
|
"ts",
|
|
1967
1887
|
"js",
|
|
1968
1888
|
"pm",
|
|
1889
|
+
"layout",
|
|
1969
1890
|
"render",
|
|
1891
|
+
"with",
|
|
1970
1892
|
"sample-data",
|
|
1971
1893
|
"no-git"
|
|
1972
1894
|
]
|
|
@@ -2033,11 +1955,23 @@ async function runCommandLine(argv, io, designSystem) {
|
|
|
2033
1955
|
io.write("--ts and --js do not go together: give one.\n");
|
|
2034
1956
|
return 1;
|
|
2035
1957
|
}
|
|
1958
|
+
const libraries = values.with?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
1959
|
+
const unknownLibrary = libraries?.find((name) => !LIBRARY_NAMES.includes(name));
|
|
1960
|
+
if (unknownLibrary !== void 0) {
|
|
1961
|
+
io.write(`--with takes ${LIBRARY_NAMES.join(", ")}, not ${unknownLibrary}.\n`);
|
|
1962
|
+
return 1;
|
|
1963
|
+
}
|
|
2036
1964
|
const { render } = values;
|
|
2037
1965
|
if (render !== void 0 && !RENDERINGS.includes(render)) {
|
|
2038
1966
|
io.write(`--render is ${RENDERINGS.join(", ")}, not ${render}.\n`);
|
|
2039
1967
|
return 1;
|
|
2040
1968
|
}
|
|
1969
|
+
const { layout } = values;
|
|
1970
|
+
if (layout !== void 0 && !LAYOUTS.includes(layout)) {
|
|
1971
|
+
io.write(`--layout is ${LAYOUTS.join(", ")}, not ${layout}.
|
|
1972
|
+
`);
|
|
1973
|
+
return 1;
|
|
1974
|
+
}
|
|
2041
1975
|
const { pm } = values;
|
|
2042
1976
|
if (pm !== void 0 && !PACKAGE_MANAGERS.includes(pm)) {
|
|
2043
1977
|
io.write(`--pm is ${PACKAGE_MANAGERS.join(", ")}, not ${pm}.\n`);
|
|
@@ -2053,7 +1987,9 @@ async function runCommandLine(argv, io, designSystem) {
|
|
|
2053
1987
|
framework: values.framework,
|
|
2054
1988
|
isTypeScript,
|
|
2055
1989
|
packageManager: pm,
|
|
1990
|
+
layout,
|
|
2056
1991
|
rendering: render,
|
|
1992
|
+
libraries,
|
|
2057
1993
|
scheme,
|
|
2058
1994
|
hasSampleData: values["sample-data"],
|
|
2059
1995
|
isConfirmed,
|