create-fluixi 1.0.0-alpha.109 → 1.0.0-alpha.111
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/dist/index.js +49 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ var TAG_INTRINSICS = {
|
|
|
43
43
|
var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
|
|
44
44
|
|
|
45
45
|
// src/index.ts
|
|
46
|
-
import { cpSync, renameSync, readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3 } from "node:fs";
|
|
46
|
+
import { cpSync, renameSync, readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, rmSync } from "node:fs";
|
|
47
47
|
import { resolve, basename, join as join2 } from "node:path";
|
|
48
48
|
import { fileURLToPath } from "node:url";
|
|
49
49
|
|
|
@@ -656,6 +656,7 @@ Scaffold a Fluixi app in dir. What is not given is asked for.
|
|
|
656
656
|
|
|
657
657
|
--ssr | --spa rendered on the server or in the browser, both with @fluixi/start
|
|
658
658
|
--jsx | --html template syntax
|
|
659
|
+
--document the page shell as a component (src/document.tsx) instead of index.html
|
|
659
660
|
--ui | --no-ui @fluixi-ui components
|
|
660
661
|
--fluixi-css | --tailwind | --no-css
|
|
661
662
|
--auth=oauth2|better-auth authentication; --no-auth for none
|
|
@@ -666,7 +667,7 @@ Scaffold a Fluixi app in dir. What is not given is asked for.
|
|
|
666
667
|
npm keeps options for itself unless they follow --:
|
|
667
668
|
npm create fluixi@alpha -- my-app --spa
|
|
668
669
|
`;
|
|
669
|
-
var FLAGS = /* @__PURE__ */ new Set(["--ssr", "--spa", "--jsx", "--html", "--ui", "--no-ui", "--tailwind", "--fluixi-css", "--no-css", "--no-auth", "--help", "-h"]);
|
|
670
|
+
var FLAGS = /* @__PURE__ */ new Set(["--ssr", "--spa", "--jsx", "--html", "--document", "--ui", "--no-ui", "--tailwind", "--fluixi-css", "--no-css", "--no-auth", "--help", "-h"]);
|
|
670
671
|
var VALUED = ["auth", "provider", "tokens"];
|
|
671
672
|
var option = (args, name) => {
|
|
672
673
|
const i = args.indexOf(`--${name}`);
|
|
@@ -687,9 +688,9 @@ function addDeps(pkg, section, deps) {
|
|
|
687
688
|
Object.entries({ ...pkg[section] ?? {}, ...deps }).sort(([a], [b]) => a.localeCompare(b))
|
|
688
689
|
);
|
|
689
690
|
}
|
|
690
|
-
function styleSheet(ui, css) {
|
|
691
|
+
function styleSheet(ui, css, shell) {
|
|
691
692
|
const darkVariant = `@custom-variant dark (&:where([data-theme='dark'], [data-theme='dark'] *));`;
|
|
692
|
-
const sources = `@source '.';
|
|
693
|
+
const sources = shell === "document" ? `@source '.';` : `@source '.';
|
|
693
694
|
@source '../index.html';`;
|
|
694
695
|
const theme = `@theme {
|
|
695
696
|
/* Design tokens. A --color-* scale here drives the whole app. */
|
|
@@ -746,6 +747,47 @@ function importStyles(target, ui, css) {
|
|
|
746
747
|
].join("\n");
|
|
747
748
|
writeFileSync3(file, head + readFileSync3(file, "utf8"));
|
|
748
749
|
}
|
|
750
|
+
function writeDocument(target, format) {
|
|
751
|
+
const index = join2(target, "index.html");
|
|
752
|
+
const title = /<title>([^<]*)<\/title>/.exec(readFileSync3(index, "utf8"))?.[1] ?? "Fluixi";
|
|
753
|
+
const head = `<meta charset="UTF-8" />
|
|
754
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
755
|
+
<title>${title}</title>`;
|
|
756
|
+
const source = format === "html" ? `import { html } from '@fluixi/core';
|
|
757
|
+
import { Html, Head, Main, Scripts } from '@fluixi/start/document';
|
|
758
|
+
|
|
759
|
+
// Rendered on the server for each request; only the app inside Main hydrates.
|
|
760
|
+
export default function Document() {
|
|
761
|
+
return html\`<\${Html} lang="en">
|
|
762
|
+
<\${Head}>
|
|
763
|
+
${head}
|
|
764
|
+
</\${Head}>
|
|
765
|
+
<body>
|
|
766
|
+
<\${Main} />
|
|
767
|
+
<\${Scripts} />
|
|
768
|
+
</body>
|
|
769
|
+
</\${Html}>\`;
|
|
770
|
+
}
|
|
771
|
+
` : `import { Html, Head, Main, Scripts } from '@fluixi/start/document';
|
|
772
|
+
|
|
773
|
+
// Rendered on the server for each request; only the app inside Main hydrates.
|
|
774
|
+
export default function Document() {
|
|
775
|
+
return (
|
|
776
|
+
<Html lang="en">
|
|
777
|
+
<Head>
|
|
778
|
+
${head}
|
|
779
|
+
</Head>
|
|
780
|
+
<body>
|
|
781
|
+
<Main />
|
|
782
|
+
<Scripts />
|
|
783
|
+
</body>
|
|
784
|
+
</Html>
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
`;
|
|
788
|
+
writeFileSync3(join2(target, "src", format === "html" ? "document.ts" : "document.tsx"), source);
|
|
789
|
+
rmSync(index);
|
|
790
|
+
}
|
|
749
791
|
async function main() {
|
|
750
792
|
const args = argv.slice(2);
|
|
751
793
|
if (args.includes("--help") || args.includes("-h")) {
|
|
@@ -754,6 +796,7 @@ async function main() {
|
|
|
754
796
|
}
|
|
755
797
|
let dir = args.find((a) => !a.startsWith("-"));
|
|
756
798
|
let mode = args.includes("--spa") ? "spa" : args.includes("--ssr") ? "ssr" : void 0;
|
|
799
|
+
const document = args.includes("--document");
|
|
757
800
|
let format = args.includes("--html") ? "html" : args.includes("--jsx") ? "jsx" : void 0;
|
|
758
801
|
let ui = args.includes("--ui") ? "fluixi-ui" : args.includes("--no-ui") ? "none" : void 0;
|
|
759
802
|
let css = args.includes("--tailwind") ? "tailwind" : args.includes("--fluixi-css") ? "fluixi-css" : args.includes("--no-css") ? "none" : void 0;
|
|
@@ -838,6 +881,7 @@ ${BAR2}
|
|
|
838
881
|
}
|
|
839
882
|
const template = `../template-${mode}${format === "html" ? "-html" : ""}`;
|
|
840
883
|
cpSync(here(template), target, { recursive: true });
|
|
884
|
+
if (document) writeDocument(target, format);
|
|
841
885
|
const gi = join2(target, "_gitignore");
|
|
842
886
|
if (existsSync3(gi)) renameSync(gi, join2(target, ".gitignore"));
|
|
843
887
|
writeFileSync3(join2(target, "fluixi.d.ts"), INTRINSICS_DTS);
|
|
@@ -866,7 +910,7 @@ ${BAR2}
|
|
|
866
910
|
}
|
|
867
911
|
if (ui === "fluixi-ui" || css !== "none") {
|
|
868
912
|
if (css === "fluixi-css") writeFileSync3(join2(target, "src", "layers.css"), LAYERS_CSS);
|
|
869
|
-
const sheet = styleSheet(ui, css);
|
|
913
|
+
const sheet = styleSheet(ui, css, document ? "document" : "index");
|
|
870
914
|
writeFileSync3(join2(target, "src", "styles.css"), sheet);
|
|
871
915
|
importStyles(target, ui, css);
|
|
872
916
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-fluixi",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.111",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Ibrahima Touré",
|
|
6
6
|
"description": "Scaffold a new Fluixi app — `npm create fluixi <dir>`.",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"esbuild": "^0.24.0",
|
|
31
31
|
"vitest": "^5.0.3",
|
|
32
|
-
"@fluixi/cli": "1.0.0-alpha.
|
|
33
|
-
"@fluixi/compiler": "1.0.0-alpha.
|
|
32
|
+
"@fluixi/cli": "1.0.0-alpha.111",
|
|
33
|
+
"@fluixi/compiler": "1.0.0-alpha.111"
|
|
34
34
|
},
|
|
35
35
|
"nx": {
|
|
36
36
|
"targets": {
|