create-fluixi 0.1.0-alpha.12 → 0.1.0-alpha.14
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 +842 -373
- package/package.json +18 -2
- package/template-spa/_gitignore +1 -0
- package/template-spa/package.json +1 -0
- package/template-spa-html/_gitignore +1 -0
- package/template-spa-html/package.json +1 -0
- package/template-ssr/_gitignore +1 -0
- package/template-ssr/package.json +1 -0
- package/template-ssr/src/entry-server.ts +5 -0
- package/template-ssr-html/_gitignore +1 -0
- package/template-ssr-html/package.json +1 -0
- package/template-ssr-html/src/entry-server.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -1,405 +1,874 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
|
|
3
|
+
// ../compiler/dist/analyze/intrinsics.mjs
|
|
4
|
+
var REACTIVE_MODULE = "@fluixi/reactive/signal";
|
|
5
|
+
var INTRINSICS = {
|
|
6
|
+
$signal: { export: "signal", module: REACTIVE_MODULE, returns: "signal-handle" },
|
|
7
|
+
$memo: { export: "memo", module: REACTIVE_MODULE, returns: "memo-handle" },
|
|
8
|
+
$effect: { export: "effect", module: REACTIVE_MODULE, returns: "effect" },
|
|
9
|
+
$store: { export: "store", module: "@fluixi/reactive/store", returns: "store-handle" },
|
|
10
|
+
$resource: { export: "resource", module: REACTIVE_MODULE, returns: "resource-handle" },
|
|
11
|
+
$cachedResource: { export: "cachedResource", module: "@fluixi/reactive/cached-resource", returns: "resource-handle" },
|
|
12
|
+
// No short runtime form for these yet, so the intrinsic stands for the `create*`
|
|
13
|
+
// name. Still worth having: no import to write, and when a shorter form is
|
|
14
|
+
// designed, the change is this line rather than a compiler pass.
|
|
15
|
+
$selector: { export: "createSelector", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
16
|
+
$deferred: { export: "createDeferred", module: REACTIVE_MODULE, returns: "memo-accessor" },
|
|
17
|
+
// Not value constructors, but the compiler has to know them: they change what a read
|
|
18
|
+
// does. `untrack` suppresses dependency collection, which is exactly the kind of thing
|
|
19
|
+
// dependency analysis must not guess at.
|
|
20
|
+
$untrack: { export: "untrack", module: REACTIVE_MODULE, returns: "plain" },
|
|
21
|
+
$untrackStore: { export: "untrackStore", module: "@fluixi/reactive/store", returns: "plain" },
|
|
22
|
+
// Scopes, scheduling and lifecycle: no value to classify, but the same authoring promise,
|
|
23
|
+
// no import to write. `$cleanup` registers a callback on the current owner (`onCleanup`).
|
|
24
|
+
$batch: { export: "batch", module: REACTIVE_MODULE, returns: "plain" },
|
|
25
|
+
$cleanup: { export: "onCleanup", module: REACTIVE_MODULE, returns: "plain" },
|
|
26
|
+
$root: { export: "root", module: REACTIVE_MODULE, returns: "plain" },
|
|
27
|
+
$context: { export: "context", module: REACTIVE_MODULE, returns: "plain" },
|
|
28
|
+
$renderEffect: { export: "renderEffect", module: REACTIVE_MODULE, returns: "effect" },
|
|
29
|
+
$computed: { export: "computed", module: REACTIVE_MODULE, returns: "effect" },
|
|
30
|
+
// Storage for where the code runs, and a signal kept in it. `$persisted` is a signal
|
|
31
|
+
// handle as far as reads go: the same accessor with `set` on it.
|
|
32
|
+
$storage: { export: "useStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
33
|
+
$asyncStorage: { export: "useAsyncStorage", module: "@fluixi/core/storage", returns: "plain" },
|
|
34
|
+
$persisted: { export: "persisted", module: "@fluixi/core/storage", returns: "signal-handle" },
|
|
35
|
+
// An environment variable, public or server-only; the browser build refuses a secret.
|
|
36
|
+
$env: { export: "env", module: "@fluixi/start/env", returns: "plain" }
|
|
25
37
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
var INTRINSIC_CALL = new RegExp(`\\$(?:${Object.keys(INTRINSICS).map((n) => n.slice(1)).join("|")})\\s*\\(`);
|
|
39
|
+
|
|
40
|
+
// src/index.ts
|
|
41
|
+
import { cpSync, renameSync, readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3 } from "node:fs";
|
|
42
|
+
import { resolve, basename, join as join2 } from "node:path";
|
|
43
|
+
import { fileURLToPath } from "node:url";
|
|
44
|
+
|
|
45
|
+
// ../cli/dist/scaffold/index.mjs
|
|
46
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
47
|
+
import { dirname as dirname2, join, relative } from "node:path";
|
|
48
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
49
|
+
import { dirname } from "node:path";
|
|
50
|
+
import { createInterface } from "node:readline/promises";
|
|
51
|
+
import { emitKeypressEvents } from "node:readline";
|
|
52
|
+
import { stdin as input, stdout as output, exit, env } from "node:process";
|
|
53
|
+
var __defProp = Object.defineProperty;
|
|
54
|
+
var __export = (target, all) => {
|
|
55
|
+
for (var name in all)
|
|
56
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
57
|
+
};
|
|
58
|
+
function closing(text, open) {
|
|
59
|
+
let depth = 0;
|
|
60
|
+
for (let i = open; i < text.length; i++) {
|
|
61
|
+
const ch = text[i];
|
|
62
|
+
if (ch === "/" && text[i + 1] === "/") i = text.indexOf("\n", i) === -1 ? text.length : text.indexOf("\n", i);
|
|
63
|
+
else if (ch === "/" && text[i + 1] === "*") i = text.indexOf("*/", i + 2) + 1;
|
|
64
|
+
else if (ch === "'" || ch === '"' || ch === "`") {
|
|
65
|
+
for (i++; i < text.length && text[i] !== ch; i++) if (text[i] === "\\") i++;
|
|
66
|
+
} else if ("([{".includes(ch)) depth++;
|
|
67
|
+
else if (")]}".includes(ch) && --depth === 0) return i;
|
|
68
|
+
}
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
function appendToArray(text, open, items) {
|
|
72
|
+
const close = closing(text, open);
|
|
73
|
+
const inner = text.slice(open + 1, close);
|
|
74
|
+
if (!inner.trim()) return text.slice(0, open + 1) + items.join(", ") + text.slice(close);
|
|
75
|
+
if (inner.includes("\n")) {
|
|
76
|
+
const last = inner.trimEnd();
|
|
77
|
+
const indent = last.slice(last.lastIndexOf("\n") + 1).match(/^\s*/)[0];
|
|
78
|
+
const comma = last.endsWith(",") ? "" : ",";
|
|
79
|
+
const tail = inner.slice(last.length);
|
|
80
|
+
return text.slice(0, open + 1) + last + comma + items.map((i) => `
|
|
81
|
+
${indent}${i},`).join("") + tail + text.slice(close);
|
|
82
|
+
}
|
|
83
|
+
const body = inner.replace(/,?\s*$/, "");
|
|
84
|
+
const trailing = inner.slice(body.length).replace(/^,/, "");
|
|
85
|
+
return text.slice(0, open + 1) + body + ", " + items.join(", ") + trailing + text.slice(close);
|
|
86
|
+
}
|
|
87
|
+
function addImport(text, line) {
|
|
88
|
+
if (text.includes(line)) return text;
|
|
89
|
+
const imports = [...text.matchAll(/^import[\s\S]*?from\s+['"][^'"]+['"];?[^\n]*\n/gm)];
|
|
90
|
+
const at = imports.length ? imports[imports.length - 1].index + imports[imports.length - 1][0].length : 0;
|
|
91
|
+
return text.slice(0, at) + line + "\n" + text.slice(at);
|
|
92
|
+
}
|
|
93
|
+
function register(log, file, header, r) {
|
|
94
|
+
const imports = [...r.extraImports ?? [], r.importLine];
|
|
95
|
+
if (!existsSync(file)) {
|
|
96
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
97
|
+
writeFileSync(
|
|
98
|
+
file,
|
|
99
|
+
`${header}import { defineApp } from '@fluixi/start/app';
|
|
100
|
+
${imports.join("\n")}
|
|
101
|
+
|
|
102
|
+
export default defineApp({ imports: [${r.entry}] });
|
|
103
|
+
`
|
|
104
|
+
);
|
|
105
|
+
log.push({ kind: "created", file });
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
let text = readFileSync(file, "utf8");
|
|
109
|
+
if (text.includes(r.importLine)) {
|
|
110
|
+
log.push({ kind: "listed", file, detail: r.entry });
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
const m = text.match(/\bimports\s*:\s*\[/);
|
|
114
|
+
if (!m) {
|
|
115
|
+
log.push({ kind: "hint", file, lines: [...imports, `imports: [${r.entry}]`] });
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
text = appendToArray(text, m.index + m[0].length - 1, [r.entry]);
|
|
119
|
+
for (const line of imports) text = addImport(text, line);
|
|
120
|
+
writeFileSync(file, text);
|
|
121
|
+
log.push({ kind: "updated", file, detail: `imports ${r.entry}` });
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
function envPublicNames(configFile) {
|
|
125
|
+
if (!existsSync(configFile)) return null;
|
|
126
|
+
const text = readFileSync(configFile, "utf8");
|
|
127
|
+
const m = text.match(/\bpublic\s*:\s*\[/);
|
|
128
|
+
if (!m) return null;
|
|
129
|
+
const open = m.index + m[0].length - 1;
|
|
130
|
+
const list = text.slice(open, closing(text, open) + 1);
|
|
131
|
+
return [...list.matchAll(/['"]([A-Za-z_][A-Za-z0-9_]*)['"]/g)].map((x) => x[1]);
|
|
132
|
+
}
|
|
133
|
+
function addEnvPublic(log, configFile, names) {
|
|
134
|
+
const list = (indent) => `${indent}public: [
|
|
135
|
+
${names.map((n) => `${indent} '${n}',
|
|
136
|
+
`).join("")}${indent}],
|
|
137
|
+
`;
|
|
138
|
+
const have = envPublicNames(configFile);
|
|
139
|
+
if (have === null) {
|
|
140
|
+
const text2 = existsSync(configFile) ? readFileSync(configFile, "utf8") : "";
|
|
141
|
+
const call = text2.match(/defineConfig\(\{\n/);
|
|
142
|
+
if (call && !/\benv\s*:/.test(text2)) {
|
|
143
|
+
const at = call.index + call[0].length;
|
|
144
|
+
writeFileSync(configFile, text2.slice(0, at) + ` env: {
|
|
145
|
+
${list(" ")} },
|
|
146
|
+
` + text2.slice(at));
|
|
147
|
+
log.push({ kind: "updated", file: configFile, detail: `env.public ${names.join(", ")}` });
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
log.push({ kind: "hint", file: configFile, lines: [`env: { public: [${names.map((n) => `'${n}'`).join(", ")}] },`] });
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const missing = names.filter((n) => !have.includes(n));
|
|
154
|
+
if (!missing.length) return;
|
|
155
|
+
const text = readFileSync(configFile, "utf8");
|
|
156
|
+
const m = text.match(/\bpublic\s*:\s*\[/);
|
|
157
|
+
writeFileSync(configFile, appendToArray(text, m.index + m[0].length - 1, missing.map((n) => `'${n}'`)));
|
|
158
|
+
log.push({ kind: "updated", file: configFile, detail: `env.public + ${missing.join(", ")}` });
|
|
159
|
+
}
|
|
160
|
+
function addEnvExample(log, file, comment, vars) {
|
|
161
|
+
const text = existsSync(file) ? readFileSync(file, "utf8") : "";
|
|
162
|
+
const have = new Set([...text.matchAll(/^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/gm)].map((m) => m[1]));
|
|
163
|
+
const add = Object.entries(vars).filter(([k]) => !have.has(k) && !have.has(`VITE_${k}`));
|
|
164
|
+
if (!add.length) return;
|
|
165
|
+
const block = `${comment.split("\n").map((l) => `# ${l}`).join("\n")}
|
|
166
|
+
${add.map(([k, v]) => `${k}=${v}`).join("\n")}
|
|
167
|
+
`;
|
|
168
|
+
writeFileSync(file, text ? `${text.replace(/\n*$/, "\n")}
|
|
169
|
+
${block}` : block);
|
|
170
|
+
log.push({ kind: text ? "updated" : "created", file, detail: add.map(([k]) => k).join(", ") });
|
|
171
|
+
}
|
|
172
|
+
var templates_exports = {};
|
|
173
|
+
__export(templates_exports, {
|
|
174
|
+
AUTH_READER: () => AUTH_READER,
|
|
175
|
+
PROVIDERS: () => PROVIDERS,
|
|
176
|
+
PROVIDER_VARS: () => PROVIDER_VARS,
|
|
177
|
+
SERVER_ONLY: () => SERVER_ONLY,
|
|
178
|
+
apiRoute: () => apiRoute,
|
|
179
|
+
authEnvConfig: () => authEnvConfig,
|
|
180
|
+
authServerFile: () => authServerFile,
|
|
181
|
+
authServiceFile: () => authServiceFile,
|
|
182
|
+
betterAuthClient: () => betterAuthClient,
|
|
183
|
+
betterAuthConfig: () => betterAuthConfig,
|
|
184
|
+
betterAuthMiddleware: () => betterAuthMiddleware,
|
|
185
|
+
betterAuthRoute: () => betterAuthRoute,
|
|
186
|
+
callbackRoute: () => callbackRoute,
|
|
187
|
+
camel: () => camel,
|
|
188
|
+
envConfig: () => envConfig,
|
|
189
|
+
guardedApiRoute: () => guardedApiRoute,
|
|
190
|
+
loginRoute: () => loginRoute,
|
|
191
|
+
moduleFile: () => moduleFile,
|
|
192
|
+
serverFn: () => serverFn,
|
|
193
|
+
serviceFile: () => serviceFile,
|
|
194
|
+
verifyServer: () => verifyServer
|
|
195
|
+
});
|
|
196
|
+
var camel = (name) => name.toLowerCase().replace(/_+([a-z0-9])/g, (_, ch) => ch.toUpperCase());
|
|
197
|
+
var envConfig = (names) => {
|
|
198
|
+
const fields = names.length ? names.map((n) => ` ${camel(n)}: '${n}',`).join("\n") : ` // apiUrl: 'API_URL',`;
|
|
199
|
+
return `import { pickEnv } from '@fluixi/start/env';
|
|
200
|
+
|
|
201
|
+
// Every missing variable is reported at once, when this module loads. A field that may be
|
|
202
|
+
// unset takes { key, optional: true } or { key, default }; parse: asNumber and friends convert.
|
|
203
|
+
export const config = pickEnv({
|
|
204
|
+
${fields}
|
|
205
|
+
});
|
|
206
|
+
`;
|
|
207
|
+
};
|
|
208
|
+
var moduleFile = (Name, name) => `import { defineModule } from '@fluixi/start/app';
|
|
209
|
+
|
|
210
|
+
export const ${Name}Module = defineModule({
|
|
211
|
+
name: '${name}',
|
|
212
|
+
imports: [],
|
|
213
|
+
providers: [],
|
|
214
|
+
});
|
|
215
|
+
`;
|
|
216
|
+
var serviceFile = (Name, name, server) => `${server ? `// Server only: the browser build refuses a page that imports this file.
|
|
217
|
+
` : ""}import { injectionToken } from '@fluixi/start/di';
|
|
218
|
+
import { defineModule } from '@fluixi/start/app';
|
|
219
|
+
|
|
220
|
+
export class ${Name}Service {}
|
|
221
|
+
|
|
222
|
+
export const ${Name}Token = injectionToken<${Name}Service>('${Name}');
|
|
223
|
+
|
|
224
|
+
export const ${Name}Module = defineModule({
|
|
225
|
+
name: '${name}',
|
|
226
|
+
providers: [{ provide: ${Name}Token, useFactory: () => new ${Name}Service() }],
|
|
227
|
+
});
|
|
228
|
+
`;
|
|
229
|
+
var apiRoute = () => `export function GET(request: Request) {
|
|
230
|
+
return Response.json({ path: new URL(request.url).pathname });
|
|
231
|
+
}
|
|
232
|
+
`;
|
|
233
|
+
var guardedApiRoute = (guardImport, role) => `import { guard } from '${guardImport}';
|
|
234
|
+
|
|
235
|
+
export const GET = guard(
|
|
236
|
+
async (request, claims) => {
|
|
237
|
+
return Response.json({ sub: claims.sub });
|
|
238
|
+
},
|
|
239
|
+
{ role: '${role}' },
|
|
240
|
+
);
|
|
241
|
+
`;
|
|
242
|
+
var verifyServer = () => `import { createTokenVerifier, createApiGuard } from '@fluixi/oauth2/verify';
|
|
243
|
+
import { auth } from '../config/env.js';
|
|
244
|
+
|
|
245
|
+
// Checks a bearer token's signature, issuer, audience and expiry against the provider.
|
|
246
|
+
export const verify = createTokenVerifier(auth.provider.verifier(auth.clientId));
|
|
247
|
+
|
|
248
|
+
// Answers 401 without a valid token and 403 without the role.
|
|
249
|
+
export const guard = createApiGuard({ verify, roles: auth.provider.roles });
|
|
250
|
+
`;
|
|
251
|
+
var serverFn = (name) => `export async function ${name}(input: { id: string }) {
|
|
252
|
+
'use server';
|
|
253
|
+
// Runs on the server only. The browser calls it over RPC, so input and result are plain data.
|
|
254
|
+
return { id: input.id };
|
|
255
|
+
}
|
|
256
|
+
`;
|
|
257
|
+
var PROVIDERS = ["oidc", "keycloak", "auth0", "okta", "google", "dex", "oauth2"];
|
|
258
|
+
var SERVER_ONLY = {
|
|
259
|
+
google: "Google answers a token request without a client secret with `client_secret is missing`",
|
|
260
|
+
dex: "Dex sends no CORS headers on discovery or the token endpoint"
|
|
261
|
+
};
|
|
262
|
+
var PROVIDER_VARS = {
|
|
263
|
+
oidc: { AUTH_ISSUER: "https://id.example.com" },
|
|
264
|
+
keycloak: { AUTH_BASE_URL: "http://localhost:8080", AUTH_REALM: "master" },
|
|
265
|
+
auth0: { AUTH_DOMAIN: "example.eu.auth0.com", AUTH_AUDIENCE: "https://api.example.com" },
|
|
266
|
+
okta: { AUTH_DOMAIN: "example.okta.com" },
|
|
267
|
+
google: {},
|
|
268
|
+
dex: { AUTH_BASE_URL: "http://localhost:5556/dex" },
|
|
269
|
+
oauth2: {
|
|
270
|
+
AUTH_ISSUER: "https://id.example.com",
|
|
271
|
+
AUTH_AUTHORIZATION_ENDPOINT: "https://id.example.com/authorize",
|
|
272
|
+
AUTH_TOKEN_ENDPOINT: "https://id.example.com/token"
|
|
273
|
+
}
|
|
38
274
|
};
|
|
39
|
-
|
|
40
|
-
//
|
|
275
|
+
var AUTH_READER = `// Provider, issuer, client and token mode from the AUTH_* variables in env.public. Moving to
|
|
276
|
+
// another provider is a change to .env.
|
|
277
|
+
export const auth = authFromEnv(publicEnv(), { clientPrefix: '' });
|
|
278
|
+
`;
|
|
279
|
+
var authEnvConfig = () => `import { publicEnv } from '@fluixi/start/env';
|
|
280
|
+
import { authFromEnv } from '@fluixi/oauth2/env';
|
|
281
|
+
|
|
282
|
+
${AUTH_READER}`;
|
|
283
|
+
var authServiceFile = (tokens) => `import { createAuthService, authModule } from '@fluixi/oauth2';
|
|
284
|
+
import { env } from '@fluixi/start/env';
|
|
285
|
+
${tokens === "browser" ? `import { auth as authEnv } from '../config/env.js';
|
|
286
|
+
` : ""}
|
|
287
|
+
export interface User {
|
|
288
|
+
sub: string;
|
|
289
|
+
email?: string;
|
|
290
|
+
name?: string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const appUrl = env('APP_URL') ?? 'http://localhost:3000';
|
|
294
|
+
|
|
295
|
+
export const auth = createAuthService<User>({
|
|
296
|
+
${tokens === "browser" ? ` config: {
|
|
297
|
+
...authEnv.client,
|
|
298
|
+
tokens: 'browser',
|
|
299
|
+
redirectUri: \`\${appUrl}/callback\`,
|
|
300
|
+
postLogoutRedirectUri: \`\${appUrl}/login\`,
|
|
301
|
+
},` : ` // The tokens stay on the server behind an httpOnly cookie. The browser calls the routes
|
|
302
|
+
// auth.server.ts mounts under basePath and never sees a token.
|
|
303
|
+
config: {
|
|
304
|
+
tokens: 'server',
|
|
305
|
+
redirectUri: \`\${appUrl}/auth/callback\`,
|
|
306
|
+
postLogoutRedirectUri: \`\${appUrl}/login\`,
|
|
307
|
+
basePath: '/auth',
|
|
308
|
+
},`}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
export const AuthModule = authModule(auth);
|
|
312
|
+
export const { protectedRoute, Protect, Can, useUser } = auth;
|
|
313
|
+
`;
|
|
314
|
+
var authServerFile = () => `import { authServerModule } from '@fluixi/oauth2/server';
|
|
315
|
+
import { publicEnv, serverEnv } from '@fluixi/start/env';
|
|
316
|
+
import { auth } from '../config/env.js';
|
|
317
|
+
|
|
318
|
+
// A function: serverEnv with required throws when a secret is unset, and it is only read
|
|
319
|
+
// when app.config.server.ts registers this.
|
|
320
|
+
export function authServer() {
|
|
321
|
+
const appUrl = publicEnv().APP_URL ?? 'http://localhost:3000';
|
|
322
|
+
return authServerModule({
|
|
323
|
+
...auth.client,
|
|
324
|
+
clientSecret: serverEnv('OIDC_CLIENT_SECRET', { required: true }),
|
|
325
|
+
cookieSecret: serverEnv('SESSION_SECRET', { required: true }),
|
|
326
|
+
redirectUri: \`\${appUrl}/auth/callback\`,
|
|
327
|
+
defaultReturnTo: '/',
|
|
328
|
+
secureCookie: appUrl.startsWith('https://'),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
`;
|
|
332
|
+
var callbackRoute = (html) => html ? `import { html } from '@fluixi/core';
|
|
333
|
+
import { OAuthCallback } from '@fluixi/oauth2/callback';
|
|
334
|
+
|
|
335
|
+
export default OAuthCallback({
|
|
336
|
+
pending: () => html\`<p>Signing you in</p>\`,
|
|
337
|
+
failed: (reason) => html\`<p>\${reason}</p><a href="/login">Try again</a>\`,
|
|
338
|
+
});
|
|
339
|
+
` : `import { OAuthCallback } from '@fluixi/oauth2/callback';
|
|
340
|
+
|
|
341
|
+
export default OAuthCallback({
|
|
342
|
+
pending: () => <p>Signing you in</p>,
|
|
343
|
+
failed: (reason) => (
|
|
344
|
+
<>
|
|
345
|
+
<p>{reason}</p>
|
|
346
|
+
<a href="/login">Try again</a>
|
|
347
|
+
</>
|
|
348
|
+
),
|
|
349
|
+
});
|
|
350
|
+
`;
|
|
351
|
+
var loginRoute = (html) => html ? `import { html } from '@fluixi/core';
|
|
352
|
+
import { auth } from '../services/auth.js';
|
|
353
|
+
|
|
354
|
+
export default function Login() {
|
|
355
|
+
return html\`<button @click=\${() => auth.signIn({ returnTo: '/' })}>Sign in</button>\`;
|
|
356
|
+
}
|
|
357
|
+
` : `import { auth } from '../services/auth.js';
|
|
358
|
+
|
|
359
|
+
export default function Login() {
|
|
360
|
+
return <button onClick={() => auth.signIn({ returnTo: '/' })}>Sign in</button>;
|
|
361
|
+
}
|
|
362
|
+
`;
|
|
363
|
+
var betterAuthConfig = () => `import { betterAuth } from 'better-auth';
|
|
364
|
+
import { defineAuth } from '@fluixi/auth/server';
|
|
365
|
+
|
|
366
|
+
export type AppUser = { id: string; email: string; name?: string; role?: string };
|
|
367
|
+
|
|
368
|
+
// Better Auth owns the audited primitives; defineAuth registers it with @fluixi/auth.
|
|
369
|
+
export const auth = defineAuth<AppUser>(
|
|
370
|
+
betterAuth({
|
|
371
|
+
// database: <your adapter>,
|
|
372
|
+
emailAndPassword: { enabled: true },
|
|
373
|
+
// socialProviders: { google: { \u2026 }, github: { \u2026 } },
|
|
374
|
+
} as Parameters<typeof betterAuth>[0]),
|
|
375
|
+
);
|
|
376
|
+
`;
|
|
377
|
+
var betterAuthClient = () => `import { createAuthClient } from 'better-auth/client';
|
|
378
|
+
import { createAuthHooks } from '@fluixi/auth/client';
|
|
379
|
+
import type { AppUser } from './auth.config.js';
|
|
380
|
+
|
|
381
|
+
const client = createAuthClient({ baseURL: '/api/auth' });
|
|
382
|
+
|
|
383
|
+
// Or, to reuse an existing reactive session: createAuthHooks({ session: yourSessionStore }).
|
|
384
|
+
export const { useUser, useSession, useAuth, useSignIn, useSignOut, protectedRoute } =
|
|
385
|
+
createAuthHooks<AppUser>({ client, loginPath: '/login' });
|
|
386
|
+
`;
|
|
387
|
+
var betterAuthMiddleware = () => `import { defineMiddleware } from '@fluixi/start';
|
|
388
|
+
import { authMiddleware } from '@fluixi/auth/server';
|
|
389
|
+
import './auth.config.js';
|
|
390
|
+
|
|
391
|
+
export default defineMiddleware([authMiddleware()]);
|
|
392
|
+
`;
|
|
393
|
+
var betterAuthRoute = () => `import { mountAuthRoutes } from '@fluixi/auth/server';
|
|
394
|
+
import '../../auth.config.js';
|
|
395
|
+
|
|
396
|
+
const handler = mountAuthRoutes();
|
|
397
|
+
export const GET = handler;
|
|
398
|
+
export const POST = handler;
|
|
399
|
+
export default handler;
|
|
400
|
+
`;
|
|
401
|
+
var ScaffoldError = class extends Error {
|
|
402
|
+
};
|
|
403
|
+
function importPath(from, to) {
|
|
404
|
+
const p = relative(dirname2(from), to).replace(/\\/g, "/").replace(/\.tsx?$/, ".js");
|
|
405
|
+
return p.startsWith(".") ? p : `./${p}`;
|
|
406
|
+
}
|
|
407
|
+
function writeOnce(log, file, content) {
|
|
408
|
+
if (existsSync2(file)) {
|
|
409
|
+
log.push({ kind: "kept", file });
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
mkdirSync2(dirname2(file), { recursive: true });
|
|
413
|
+
writeFileSync2(file, content);
|
|
414
|
+
log.push({ kind: "created", file });
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
var APP_HEADER = "// Registered by @fluixi/start ahead of both entries.\n";
|
|
418
|
+
var APP_SERVER_HEADER = "// Only the server build imports this file, so what it lists never reaches the browser.\n";
|
|
419
|
+
function registerModule(log, root, server, file, name, entry = name) {
|
|
420
|
+
const config = join(root, server ? "src/app.config.server.ts" : "src/app.config.ts");
|
|
421
|
+
register(log, config, server ? APP_SERVER_HEADER : APP_HEADER, {
|
|
422
|
+
importLine: `import { ${name} } from '${importPath(config, file)}';`,
|
|
423
|
+
entry
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
function ensureAuthEnv(log, root) {
|
|
427
|
+
const file = join(root, "src/config/env.ts");
|
|
428
|
+
if (writeOnce(log, file, authEnvConfig())) return;
|
|
429
|
+
let text = readFileSync2(file, "utf8");
|
|
430
|
+
if (/export\s+const\s+auth\b/.test(text)) return;
|
|
431
|
+
if (!/\bpublicEnv\b/.test(text)) text = addImport(text, `import { publicEnv } from '@fluixi/start/env';`);
|
|
432
|
+
text = addImport(text, `import { authFromEnv } from '@fluixi/oauth2/env';`);
|
|
433
|
+
writeFileSync2(file, `${text.replace(/\n*$/, "\n")}
|
|
434
|
+
${AUTH_READER}`);
|
|
435
|
+
log.push({ kind: "updated", file, detail: "auth" });
|
|
436
|
+
}
|
|
437
|
+
function resolveTokens(provider, tokens) {
|
|
438
|
+
const refusal = SERVER_ONLY[provider];
|
|
439
|
+
if (refusal && tokens === "browser") throw new ScaffoldError(`${provider} needs server tokens: ${refusal}`);
|
|
440
|
+
return { tokens: tokens ?? (refusal ? "server" : "browser"), forced: !!refusal && !tokens };
|
|
441
|
+
}
|
|
442
|
+
function setupOAuth2(root, options, dependencySpec = "alpha") {
|
|
443
|
+
const provider = options.provider ?? "oidc";
|
|
444
|
+
if (!PROVIDERS.includes(provider)) throw new ScaffoldError(`unknown provider ${provider}: ${PROVIDERS.join(", ")}`);
|
|
445
|
+
const { tokens, forced } = resolveTokens(provider, options.tokens);
|
|
446
|
+
const html = options.format === "html";
|
|
447
|
+
const ext = html ? "ts" : "tsx";
|
|
448
|
+
const steps = [];
|
|
449
|
+
const at = (rel) => join(root, rel);
|
|
450
|
+
ensureAuthEnv(steps, root);
|
|
451
|
+
const service = at("src/services/auth.ts");
|
|
452
|
+
if (writeOnce(steps, service, authServiceFile(tokens))) registerModule(steps, root, false, service, "AuthModule");
|
|
453
|
+
if (tokens === "browser") writeOnce(steps, at(`src/routes/callback.${ext}`), callbackRoute(html));
|
|
454
|
+
writeOnce(steps, at(`src/routes/login.${ext}`), loginRoute(html));
|
|
455
|
+
if (tokens === "server") {
|
|
456
|
+
const server = at("src/services/auth.server.ts");
|
|
457
|
+
if (writeOnce(steps, server, authServerFile())) registerModule(steps, root, true, server, "authServer", "authServer()");
|
|
458
|
+
}
|
|
459
|
+
const vars = {
|
|
460
|
+
AUTH_PROVIDER: provider,
|
|
461
|
+
AUTH_CLIENT_ID: "my-app",
|
|
462
|
+
AUTH_TOKENS: tokens,
|
|
463
|
+
...PROVIDER_VARS[provider],
|
|
464
|
+
APP_URL: "http://localhost:3000"
|
|
465
|
+
};
|
|
466
|
+
addEnvPublic(steps, at("fluixi.config.ts"), Object.keys(vars));
|
|
467
|
+
addEnvExample(steps, at(".env.example"), `@fluixi/oauth2 (${provider}). Listed in env.public: the browser sees them.`, vars);
|
|
468
|
+
if (tokens === "server") {
|
|
469
|
+
addEnvExample(steps, at(".env.example"), "Server only, never in env.public. SESSION_SECRET: 32 bytes or more.", {
|
|
470
|
+
OIDC_CLIENT_SECRET: "",
|
|
471
|
+
SESSION_SECRET: ""
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
const redirect = tokens === "browser" ? "/callback" : "/auth/callback";
|
|
475
|
+
return {
|
|
476
|
+
steps,
|
|
477
|
+
dependencies: { "@fluixi/oauth2": dependencySpec },
|
|
478
|
+
next: ["copy .env.example to .env and fill it in", `register <APP_URL>${redirect} as the redirect URI at the provider`],
|
|
479
|
+
notes: forced ? [`${provider} refuses a public client, so the tokens stay on the server`] : []
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
function setupBetterAuth(root, dependencySpec = "alpha") {
|
|
483
|
+
const steps = [];
|
|
484
|
+
const at = (rel) => join(root, rel);
|
|
485
|
+
writeOnce(steps, at("src/auth.config.ts"), betterAuthConfig());
|
|
486
|
+
writeOnce(steps, at("src/auth.client.ts"), betterAuthClient());
|
|
487
|
+
if (!writeOnce(steps, at("src/middleware.ts"), betterAuthMiddleware())) {
|
|
488
|
+
steps.push({
|
|
489
|
+
kind: "hint",
|
|
490
|
+
file: at("src/middleware.ts"),
|
|
491
|
+
lines: [`import { authMiddleware } from '@fluixi/auth/server';`, `import './auth.config.js';`, "authMiddleware() in the middleware list"]
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
writeOnce(steps, at("src/api/auth/[...all].ts"), betterAuthRoute());
|
|
495
|
+
return {
|
|
496
|
+
steps,
|
|
497
|
+
dependencies: { "@fluixi/auth": dependencySpec, "better-auth": "^1" },
|
|
498
|
+
next: ["set your database adapter in src/auth.config.ts"],
|
|
499
|
+
notes: []
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
var COLOR = env.NO_COLOR || env.FORCE_COLOR === "0" ? false : (!!output.isTTY || !!env.FORCE_COLOR) && env.TERM !== "dumb";
|
|
503
|
+
var sgr = (o, x) => (s) => COLOR ? `\x1B[${o}m${s}\x1B[${x}m` : `${s}`;
|
|
504
|
+
var c = { bold: sgr(1, 22), green: sgr(32, 39), cyan: sgr(36, 39), gray: sgr(90, 39) };
|
|
505
|
+
var BAR = c.gray("\u2502");
|
|
41
506
|
async function askText(label, fallback) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
507
|
+
output.write(`${c.green("\u25C7")} ${c.bold(label)} ${c.gray(`(${fallback})`)}
|
|
508
|
+
`);
|
|
509
|
+
const rl = createInterface({ input, output });
|
|
510
|
+
const answer = (await rl.question(`${BAR} `)).trim();
|
|
511
|
+
rl.close();
|
|
512
|
+
output.write(`${BAR}
|
|
513
|
+
`);
|
|
514
|
+
return answer || fallback;
|
|
48
515
|
}
|
|
49
516
|
function askSelect(label, choices) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (input.readableEnded) {
|
|
107
|
-
finish();
|
|
108
|
-
done(choices[idx].value);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
input.on('keypress', onKey);
|
|
112
|
-
input.on('end', onEnd);
|
|
113
|
-
input.on('close', onEnd);
|
|
114
|
-
// The reason this prompt used to go nowhere. `askText` closes its readline
|
|
115
|
-
// interface, which leaves stdin paused, and `emitKeypressEvents` only wires the
|
|
116
|
-
// stream up the first time it is called. Attaching a listener to a paused stream
|
|
117
|
-
// reads nothing, so no key ever arrived: the list drew with the first option
|
|
118
|
-
// highlighted, the event loop drained, and the process exited 0 having created
|
|
119
|
-
// nothing.
|
|
120
|
-
input.resume();
|
|
121
|
-
});
|
|
517
|
+
return new Promise((done) => {
|
|
518
|
+
let idx = 0;
|
|
519
|
+
output.write(`${c.green("\u25C6")} ${c.bold(label)}
|
|
520
|
+
`);
|
|
521
|
+
const draw = (first) => {
|
|
522
|
+
if (!first) output.write(`\x1B[${choices.length}A`);
|
|
523
|
+
for (let i = 0; i < choices.length; i++) {
|
|
524
|
+
const on = i === idx;
|
|
525
|
+
const dot = on ? c.green("\u25CF") : c.gray("\u25CB");
|
|
526
|
+
const name = on ? c.cyan(c.bold(choices[i].label)) : choices[i].label;
|
|
527
|
+
output.write(`\x1B[2K${BAR} ${dot} ${name} ${c.gray(choices[i].hint)}
|
|
528
|
+
`);
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
draw(true);
|
|
532
|
+
emitKeypressEvents(input);
|
|
533
|
+
if (input.isTTY) input.setRawMode(true);
|
|
534
|
+
const onKey = (_s, k) => {
|
|
535
|
+
if (k.name === "up" || k.name === "k") {
|
|
536
|
+
idx = (idx - 1 + choices.length) % choices.length;
|
|
537
|
+
draw(false);
|
|
538
|
+
} else if (k.name === "down" || k.name === "j") {
|
|
539
|
+
idx = (idx + 1) % choices.length;
|
|
540
|
+
draw(false);
|
|
541
|
+
} else if (k.name === "return" || k.name === "enter") {
|
|
542
|
+
finish();
|
|
543
|
+
done(choices[idx].value);
|
|
544
|
+
} else if (k.name === "c" && k.ctrl) {
|
|
545
|
+
finish();
|
|
546
|
+
output.write("\n");
|
|
547
|
+
exit(1);
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
const onEnd = () => {
|
|
551
|
+
finish();
|
|
552
|
+
done(choices[idx].value);
|
|
553
|
+
};
|
|
554
|
+
const finish = () => {
|
|
555
|
+
input.off("keypress", onKey);
|
|
556
|
+
input.off("end", onEnd);
|
|
557
|
+
input.off("close", onEnd);
|
|
558
|
+
if (input.isTTY) input.setRawMode(false);
|
|
559
|
+
input.pause();
|
|
560
|
+
output.write(`${BAR}
|
|
561
|
+
`);
|
|
562
|
+
};
|
|
563
|
+
if (input.readableEnded) {
|
|
564
|
+
finish();
|
|
565
|
+
done(choices[idx].value);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
input.on("keypress", onKey);
|
|
569
|
+
input.on("end", onEnd);
|
|
570
|
+
input.on("close", onEnd);
|
|
571
|
+
input.resume();
|
|
572
|
+
});
|
|
122
573
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
574
|
+
|
|
575
|
+
// src/index.ts
|
|
576
|
+
import { stdin as input2, stdout as output2, stderr, argv, exit as exit2, env as env2 } from "node:process";
|
|
577
|
+
var here = (p) => fileURLToPath(new URL(p, import.meta.url));
|
|
578
|
+
var COLOR2 = env2.NO_COLOR || env2.FORCE_COLOR === "0" ? false : (!!output2.isTTY || !!env2.FORCE_COLOR) && env2.TERM !== "dumb";
|
|
579
|
+
var sgr2 = (o, x) => (s) => COLOR2 ? `\x1B[${o}m${s}\x1B[${x}m` : `${s}`;
|
|
580
|
+
var c2 = {
|
|
581
|
+
bold: sgr2(1, 22),
|
|
582
|
+
dim: sgr2(2, 22),
|
|
583
|
+
green: sgr2(32, 39),
|
|
584
|
+
yellow: sgr2(33, 39),
|
|
585
|
+
cyan: sgr2(36, 39),
|
|
586
|
+
gray: sgr2(90, 39),
|
|
587
|
+
red: sgr2(31, 39)
|
|
588
|
+
};
|
|
589
|
+
var rgb = (r, g, b) => (s) => COLOR2 ? `\x1B[38;2;${r};${g};${b}m${s}\x1B[39m` : s;
|
|
590
|
+
var BRAND = [
|
|
591
|
+
[34, 211, 238],
|
|
592
|
+
[56, 189, 248],
|
|
593
|
+
[129, 140, 248],
|
|
594
|
+
[167, 139, 250],
|
|
595
|
+
[192, 132, 252]
|
|
596
|
+
];
|
|
597
|
+
var gradient = (text) => {
|
|
598
|
+
if (!COLOR2) return text;
|
|
599
|
+
const ch = [...text];
|
|
600
|
+
return ch.map((x, i) => {
|
|
601
|
+
const [r, g, b] = BRAND[Math.min(BRAND.length - 1, Math.floor(i / Math.max(1, ch.length - 1) * (BRAND.length - 1)))];
|
|
602
|
+
return rgb(r, g, b)(x);
|
|
603
|
+
}).join("");
|
|
604
|
+
};
|
|
605
|
+
var BAR2 = c2.gray("\u2502");
|
|
606
|
+
var UI_DEPS = {
|
|
607
|
+
"@fluixi-ui/fx": "alpha",
|
|
608
|
+
"@fluixi-ui/interactions": "alpha",
|
|
609
|
+
"@fluixi-ui/kit": "alpha",
|
|
610
|
+
"@fluixi-ui/layout": "alpha",
|
|
611
|
+
"@fluixi-ui/polymorphic": "alpha",
|
|
612
|
+
"@fluixi-ui/primitives": "alpha",
|
|
613
|
+
"@fluixi-ui/theme": "alpha",
|
|
614
|
+
"@fluixi-ui/tokens": "alpha"
|
|
140
615
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const $signal: typeof __fluixi_reactive_signal.signal;
|
|
160
|
-
const $memo: typeof __fluixi_reactive_signal.memo;
|
|
161
|
-
const $effect: typeof __fluixi_reactive_signal.effect;
|
|
162
|
-
const $store: typeof __fluixi_reactive_store.store;
|
|
163
|
-
const $resource: typeof __fluixi_reactive_signal.resource;
|
|
164
|
-
const $selector: typeof __fluixi_reactive_signal.createSelector;
|
|
165
|
-
const $deferred: typeof __fluixi_reactive_signal.createDeferred;
|
|
166
|
-
const $untrack: typeof __fluixi_reactive_signal.untrack;
|
|
167
|
-
const $untrackStore: typeof __fluixi_reactive_store.untrackStore;
|
|
616
|
+
var UI_DEV_DEPS = { "@fluixi-ui/resolver": "alpha" };
|
|
617
|
+
var INTRINSICS_DTS = intrinsicsDts();
|
|
618
|
+
function intrinsicsDts() {
|
|
619
|
+
const reactive = Object.entries(INTRINSICS).filter(([, i]) => /^@fluixi\/(reactive|core)\//.test(i.module));
|
|
620
|
+
const alias = (module) => `__${module.slice(1).replace(/[/.-]/g, "_")}`;
|
|
621
|
+
const modules = [...new Set(reactive.map(([, i]) => i.module))].sort();
|
|
622
|
+
return [
|
|
623
|
+
"// GENERATED by @fluixi/compiler, do not edit.",
|
|
624
|
+
"//",
|
|
625
|
+
"// The reactive and storage intrinsics. They need no import. This file is rewritten on the first",
|
|
626
|
+
"// `fluixi dev`, which adds the components the resolver supplies without an import.",
|
|
627
|
+
...modules.map((m) => `import * as ${alias(m)} from '${m}';`),
|
|
628
|
+
"",
|
|
629
|
+
"declare global {",
|
|
630
|
+
...reactive.map(([name, i]) => ` const ${name}: typeof ${alias(i.module)}.${i.export};`),
|
|
631
|
+
"}",
|
|
632
|
+
""
|
|
633
|
+
].join("\n");
|
|
168
634
|
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* The cascade-layer order, declared before anything defines a layer.
|
|
172
|
-
*
|
|
173
|
-
* A layer ranks by where it is FIRST declared, and one nobody declared is appended last,
|
|
174
|
-
* which makes it the strongest. That default is wrong twice over here. The fluixi-css
|
|
175
|
-
* reset defines `flx.base`, which @fluixi-ui's own sheets do not declare, so the reset
|
|
176
|
-
* would outrank the components it is meant to sit under, and an app's plain
|
|
177
|
-
* `button { ... }` reset would outrank them too.
|
|
178
|
-
*
|
|
179
|
-
* Declaring the order up front fixes both: the app's element resets sit lowest, then the
|
|
180
|
-
* engine's preflight, then the component layers. An app's own `@layer base` and
|
|
181
|
-
* `@layer components` are deliberately absent, so they stay unregistered and keep
|
|
182
|
-
* winning, which is what an app expects of its own classes.
|
|
183
|
-
*/
|
|
184
|
-
const LAYERS_CSS = `/* Cascade-layer order. Imported before any component CSS, because a layer ranks by
|
|
635
|
+
var LAYERS_CSS = `/* Cascade-layer order. Imported before any component CSS, because a layer ranks by
|
|
185
636
|
where it is first declared and an undeclared one would rank last, above everything.
|
|
186
637
|
Add this app's own layers only if you want them to rank BELOW the component styles. */
|
|
187
638
|
@layer app-reset, flx.reset, flx.base, flx.tokens, flx.components, flx.skin;
|
|
188
639
|
`;
|
|
189
|
-
|
|
640
|
+
var option = (args, name) => {
|
|
641
|
+
const i = args.indexOf(`--${name}`);
|
|
642
|
+
if (i !== -1 && args[i + 1] && !args[i + 1].startsWith("-")) return args[i + 1];
|
|
643
|
+
return args.find((a) => a.startsWith(`--${name}=`))?.slice(name.length + 3);
|
|
644
|
+
};
|
|
645
|
+
var PROVIDER_HINTS = {
|
|
646
|
+
oidc: "any provider with a discovery document",
|
|
647
|
+
keycloak: "realm on a Keycloak server",
|
|
648
|
+
auth0: "tenant domain",
|
|
649
|
+
okta: "org domain",
|
|
650
|
+
google: "server tokens only",
|
|
651
|
+
dex: "server tokens only",
|
|
652
|
+
oauth2: "no discovery \xB7 endpoints by hand"
|
|
653
|
+
};
|
|
190
654
|
function addDeps(pkg, section, deps) {
|
|
191
|
-
|
|
655
|
+
pkg[section] = Object.fromEntries(
|
|
656
|
+
Object.entries({ ...pkg[section] ?? {}, ...deps }).sort(([a], [b]) => a.localeCompare(b))
|
|
657
|
+
);
|
|
192
658
|
}
|
|
193
|
-
/**
|
|
194
|
-
* The app's own stylesheet, in the shape the chosen css engine expects.
|
|
195
|
-
*
|
|
196
|
-
* The component tokens are not here: they are a stylesheet the package ships and the
|
|
197
|
-
* entry imports directly, so this file only holds what the engine has to read, the dark
|
|
198
|
-
* variant, where to scan, and the theme the app defines.
|
|
199
|
-
*/
|
|
200
659
|
function styleSheet(ui, css) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
// No css engine: the component tokens are imported from the entry like any other
|
|
227
|
-
// stylesheet, so there is nothing for this file to hold.
|
|
228
|
-
return '';
|
|
660
|
+
const darkVariant = `@custom-variant dark (&:where([data-theme='dark'], [data-theme='dark'] *));`;
|
|
661
|
+
const sources = `@source '.';
|
|
662
|
+
@source '../index.html';`;
|
|
663
|
+
const theme = `@theme {
|
|
664
|
+
/* Design tokens. A --color-* scale here drives the whole app. */
|
|
665
|
+
}`;
|
|
666
|
+
if (css === "fluixi-css") {
|
|
667
|
+
return [
|
|
668
|
+
darkVariant,
|
|
669
|
+
"",
|
|
670
|
+
sources,
|
|
671
|
+
"",
|
|
672
|
+
theme,
|
|
673
|
+
"",
|
|
674
|
+
"@fluixi base;",
|
|
675
|
+
"@fluixi utilities;",
|
|
676
|
+
"@fluixi components;",
|
|
677
|
+
""
|
|
678
|
+
].join("\n");
|
|
679
|
+
}
|
|
680
|
+
if (css === "tailwind") {
|
|
681
|
+
return [`@import 'tailwindcss';`, "", darkVariant, "", theme, ""].join("\n");
|
|
682
|
+
}
|
|
683
|
+
return "";
|
|
229
684
|
}
|
|
230
|
-
|
|
231
|
-
const configFor = (mode) => mode === 'ssr' ? 'fluixi.config.ts' : 'vite.config.ts';
|
|
232
|
-
/**
|
|
233
|
-
* Let a capitalised tag resolve to a @fluixi-ui package.
|
|
234
|
-
*
|
|
235
|
-
* Added alongside the rule the template ships rather than replacing it, so a local
|
|
236
|
-
* `src/components/Card.tsx` still wins and only the names it does not define fall
|
|
237
|
-
* through to the kit.
|
|
238
|
-
*/
|
|
685
|
+
var configFor = (mode) => mode === "ssr" ? "fluixi.config.ts" : "vite.config.ts";
|
|
239
686
|
function addUiResolver(target, mode) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
687
|
+
const file = join2(target, configFor(mode));
|
|
688
|
+
if (!existsSync3(file)) return;
|
|
689
|
+
let src = readFileSync3(file, "utf8");
|
|
690
|
+
src = `import { uiComponents } from '@fluixi-ui/resolver';
|
|
691
|
+
` + src;
|
|
692
|
+
src = src.replace(
|
|
693
|
+
"resolve: [{ match: /^([A-Z]\\w+)$/, module: '/src/components/$1.tsx' }]",
|
|
694
|
+
"resolve: [{ match: /^([A-Z]\\w+)$/, module: '/src/components/$1.tsx' }, uiComponents()]"
|
|
695
|
+
);
|
|
696
|
+
writeFileSync3(file, src);
|
|
247
697
|
}
|
|
248
|
-
/**
|
|
249
|
-
* Put a plugin in the app's vite config.
|
|
250
|
-
*
|
|
251
|
-
* An SSR app has none by default, because @fluixi/start owns the build. It still reads
|
|
252
|
-
* one when it is there, so a css engine that ships a vite plugin gets a file created for
|
|
253
|
-
* it rather than having nowhere to go.
|
|
254
|
-
*/
|
|
255
698
|
function addVitePlugin(target, mode, importLine, call) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
src =
|
|
264
|
-
mode === 'ssr'
|
|
265
|
-
? src.replace('export default defineConfig({', `export default defineConfig({\n plugins: [${call}],`)
|
|
266
|
-
: src.replace('plugins: [', `plugins: [\n ${call},`);
|
|
267
|
-
writeFileSync(file, src);
|
|
699
|
+
const file = join2(target, configFor(mode));
|
|
700
|
+
if (!existsSync3(file)) return;
|
|
701
|
+
let src = importLine + "\n" + readFileSync3(file, "utf8");
|
|
702
|
+
src = mode === "ssr" ? src.replace("export default defineConfig({", `export default defineConfig({
|
|
703
|
+
plugins: [${call}],`) : src.replace("plugins: [", `plugins: [
|
|
704
|
+
${call},`);
|
|
705
|
+
writeFileSync3(file, src);
|
|
268
706
|
}
|
|
269
|
-
/**
|
|
270
|
-
* Import the stylesheets from whichever file boots the client.
|
|
271
|
-
*
|
|
272
|
-
* The component tokens come first and from the entry rather than from `styles.css`:
|
|
273
|
-
* they are a stylesheet the package ships, not something the app's css engine should be
|
|
274
|
-
* asked to resolve, and the components below need them defined before their own rules
|
|
275
|
-
* land. `emitUiTokens` does not replace this, that bridge covers a subset.
|
|
276
|
-
*/
|
|
277
707
|
function importStyles(target, mode, ui, css) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
'',
|
|
290
|
-
].join('\n');
|
|
291
|
-
writeFileSync(file, head + readFileSync(file, 'utf8'));
|
|
708
|
+
const base = mode === "ssr" ? "entry-client" : "main";
|
|
709
|
+
const file = ["tsx", "ts"].map((ext) => join2(target, "src", `${base}.${ext}`)).find((p) => existsSync3(p));
|
|
710
|
+
if (!file) return;
|
|
711
|
+
const head = [
|
|
712
|
+
// First, before anything that defines a layer.
|
|
713
|
+
...css === "fluixi-css" ? [`import './layers.css';`] : [],
|
|
714
|
+
...ui === "fluixi-ui" ? [`import '@fluixi-ui/tokens/tokens.css';`] : [],
|
|
715
|
+
`import './styles.css';`,
|
|
716
|
+
""
|
|
717
|
+
].join("\n");
|
|
718
|
+
writeFileSync3(file, head + readFileSync3(file, "utf8"));
|
|
292
719
|
}
|
|
293
720
|
async function main() {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
]));
|
|
325
|
-
}
|
|
326
|
-
if (!css) {
|
|
327
|
-
css = (await askSelect('Styling', [
|
|
328
|
-
{ value: 'none', label: 'None', hint: 'plain css' },
|
|
329
|
-
{ value: 'tailwind', label: 'Tailwind CSS', hint: 'v4 · via @tailwindcss/vite' },
|
|
330
|
-
{ value: 'fluixi-css', label: '@fluixi-css', hint: 'the Fluixi stylesheet' },
|
|
331
|
-
]));
|
|
332
|
-
}
|
|
721
|
+
const args = argv.slice(2);
|
|
722
|
+
let dir = args.find((a) => !a.startsWith("-"));
|
|
723
|
+
let mode = args.includes("--spa") ? "spa" : args.includes("--ssr") ? "ssr" : void 0;
|
|
724
|
+
let format = args.includes("--html") ? "html" : args.includes("--jsx") ? "jsx" : void 0;
|
|
725
|
+
let ui = args.includes("--ui") ? "fluixi-ui" : args.includes("--no-ui") ? "none" : void 0;
|
|
726
|
+
let css = args.includes("--tailwind") ? "tailwind" : args.includes("--fluixi-css") ? "fluixi-css" : args.includes("--no-css") ? "none" : void 0;
|
|
727
|
+
let auth = args.includes("--no-auth") ? "none" : option(args, "auth");
|
|
728
|
+
let provider = option(args, "provider");
|
|
729
|
+
let tokens = option(args, "tokens");
|
|
730
|
+
const refuse = (message) => {
|
|
731
|
+
stderr.write(`${c2.red("\u2717")} ${message}
|
|
732
|
+
`);
|
|
733
|
+
exit2(1);
|
|
734
|
+
};
|
|
735
|
+
if (auth && !["none", "oauth2", "better-auth"].includes(auth)) refuse(`--auth is oauth2, better-auth or none`);
|
|
736
|
+
if (provider && !PROVIDERS.includes(provider)) refuse(`--provider is one of ${PROVIDERS.join(", ")}`);
|
|
737
|
+
if (tokens && tokens !== "browser" && tokens !== "server") refuse(`--tokens is browser or server`);
|
|
738
|
+
if (mode === "spa" && auth && auth !== "none") refuse(`authentication needs an SSR app: drop --spa or --auth`);
|
|
739
|
+
const interactive = input2.isTTY && (!dir || !mode || !format || !ui || !css || mode !== "spa" && !auth);
|
|
740
|
+
if (interactive) {
|
|
741
|
+
output2.write(`
|
|
742
|
+
${c2.gray("\u250C")} ${gradient("\u25C6")} ${c2.bold(gradient("create-fluixi"))}
|
|
743
|
+
${BAR2}
|
|
744
|
+
`);
|
|
745
|
+
if (!dir) dir = await askText("Project name", "fluixi-app");
|
|
746
|
+
if (!mode) {
|
|
747
|
+
mode = await askSelect("App mode", [
|
|
748
|
+
{ value: "ssr", label: "SSR", hint: "server-rendered \xB7 @fluixi/start" },
|
|
749
|
+
{ value: "spa", label: "SPA", hint: "client-only \xB7 vite" }
|
|
750
|
+
]);
|
|
333
751
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const target = resolve(dir);
|
|
340
|
-
const name = basename(target);
|
|
341
|
-
if (existsSync(target)) {
|
|
342
|
-
output.write(`${c.gray('└')} ${c.red('✗')} "${c.bold(name)}" already exists — pick another name or remove it.\n\n`);
|
|
343
|
-
exit(1);
|
|
752
|
+
if (!format) {
|
|
753
|
+
format = await askSelect("Template syntax", [
|
|
754
|
+
{ value: "jsx", label: "JSX", hint: "default \xB7 .tsx \xB7 html`` works inline too" },
|
|
755
|
+
{ value: "html", label: "html``", hint: "no JSX \xB7 plain .ts \xB7 @fluixi/ts-plugin" }
|
|
756
|
+
]);
|
|
344
757
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
renameSync(gi, join(target, '.gitignore'));
|
|
351
|
-
// The ambient declarations for the `$` intrinsics.
|
|
352
|
-
//
|
|
353
|
-
// The compiler rewrites this file on the first `fluixi dev`, adding whatever the
|
|
354
|
-
// resolver supplies without an import. Shipping it now means an editor knows what
|
|
355
|
-
// `$signal` is before the app has ever been run, instead of reporting "Cannot find
|
|
356
|
-
// name" across a project that compiles.
|
|
357
|
-
writeFileSync(join(target, 'fluixi.d.ts'), INTRINSICS_DTS);
|
|
358
|
-
const pkgPath = join(target, 'package.json');
|
|
359
|
-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
360
|
-
pkg.name = name;
|
|
361
|
-
if (ui === 'fluixi-ui') {
|
|
362
|
-
addDeps(pkg, 'dependencies', UI_DEPS);
|
|
363
|
-
addDeps(pkg, 'devDependencies', UI_DEV_DEPS);
|
|
364
|
-
addUiResolver(target, mode);
|
|
758
|
+
if (!ui) {
|
|
759
|
+
ui = await askSelect("Component library", [
|
|
760
|
+
{ value: "none", label: "None", hint: "bring your own components" },
|
|
761
|
+
{ value: "fluixi-ui", label: "@fluixi-ui", hint: "kit + tokens \xB7 install components as you need them" }
|
|
762
|
+
]);
|
|
365
763
|
}
|
|
366
|
-
if (css
|
|
367
|
-
|
|
368
|
-
|
|
764
|
+
if (!css) {
|
|
765
|
+
css = await askSelect("Styling", [
|
|
766
|
+
{ value: "none", label: "None", hint: "plain css" },
|
|
767
|
+
{ value: "tailwind", label: "Tailwind CSS", hint: "v4 \xB7 via @tailwindcss/vite" },
|
|
768
|
+
{ value: "fluixi-css", label: "@fluixi-css", hint: "the Fluixi stylesheet" }
|
|
769
|
+
]);
|
|
369
770
|
}
|
|
370
|
-
if (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
`fluixiCss({ reset: true${ui === 'fluixi-ui' ? ', emitUiTokens: true' : ''} })`);
|
|
377
|
-
// No `fluixi.css.config.js`: `@theme`, `@source` and `@custom-variant` in the
|
|
378
|
-
// stylesheet say the same things, and a project with both has two places to change
|
|
379
|
-
// one colour. The config file is still read when an app adds one.
|
|
771
|
+
if (mode === "ssr" && !auth) {
|
|
772
|
+
auth = await askSelect("Authentication", [
|
|
773
|
+
{ value: "none", label: "None", hint: "add it later with fluixi add auth" },
|
|
774
|
+
{ value: "oauth2", label: "OAuth2 / OIDC", hint: "@fluixi/oauth2 \xB7 Keycloak, Auth0, Okta, Google\u2026" },
|
|
775
|
+
{ value: "better-auth", label: "Better Auth", hint: "@fluixi/auth \xB7 your own user table" }
|
|
776
|
+
]);
|
|
380
777
|
}
|
|
381
|
-
if (
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
const sheet = styleSheet(ui, css);
|
|
387
|
-
// An empty sheet still gets written: it is where an app puts its own css, and the
|
|
388
|
-
// entry already imports it.
|
|
389
|
-
writeFileSync(join(target, 'src', 'styles.css'), sheet);
|
|
390
|
-
importStyles(target, mode, ui, css);
|
|
778
|
+
if (auth === "oauth2" && !provider) {
|
|
779
|
+
provider = await askSelect(
|
|
780
|
+
"Identity provider",
|
|
781
|
+
PROVIDERS.map((p) => ({ value: p, label: p, hint: PROVIDER_HINTS[p] }))
|
|
782
|
+
);
|
|
391
783
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
784
|
+
if (auth === "oauth2" && !tokens && !SERVER_ONLY[provider ?? "oidc"]) {
|
|
785
|
+
tokens = await askSelect("Where the tokens live", [
|
|
786
|
+
{ value: "browser", label: "Browser", hint: "public client \xB7 PKCE" },
|
|
787
|
+
{ value: "server", label: "Server", hint: "httpOnly cookie \xB7 client secret" }
|
|
788
|
+
]);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
dir = dir ?? "fluixi-app";
|
|
792
|
+
mode = mode ?? "ssr";
|
|
793
|
+
format = format ?? "jsx";
|
|
794
|
+
ui = ui ?? "none";
|
|
795
|
+
css = css ?? "none";
|
|
796
|
+
auth = mode === "spa" ? "none" : auth ?? "none";
|
|
797
|
+
const target = resolve(dir);
|
|
798
|
+
const name = basename(target);
|
|
799
|
+
if (existsSync3(target)) {
|
|
800
|
+
output2.write(`${c2.gray("\u2514")} ${c2.red("\u2717")} "${c2.bold(name)}" already exists \u2014 pick another name or remove it.
|
|
801
|
+
|
|
802
|
+
`);
|
|
803
|
+
exit2(1);
|
|
804
|
+
}
|
|
805
|
+
const template = `../template-${mode}${format === "html" ? "-html" : ""}`;
|
|
806
|
+
cpSync(here(template), target, { recursive: true });
|
|
807
|
+
const gi = join2(target, "_gitignore");
|
|
808
|
+
if (existsSync3(gi)) renameSync(gi, join2(target, ".gitignore"));
|
|
809
|
+
writeFileSync3(join2(target, "fluixi.d.ts"), INTRINSICS_DTS);
|
|
810
|
+
const pkgPath = join2(target, "package.json");
|
|
811
|
+
const pkg = JSON.parse(readFileSync3(pkgPath, "utf8"));
|
|
812
|
+
pkg.name = name;
|
|
813
|
+
if (ui === "fluixi-ui") {
|
|
814
|
+
addDeps(pkg, "dependencies", UI_DEPS);
|
|
815
|
+
addDeps(pkg, "devDependencies", UI_DEV_DEPS);
|
|
816
|
+
addUiResolver(target, mode);
|
|
817
|
+
}
|
|
818
|
+
if (css === "tailwind") {
|
|
819
|
+
addDeps(pkg, "devDependencies", { tailwindcss: "^4", "@tailwindcss/vite": "^4" });
|
|
820
|
+
addVitePlugin(target, mode, `import tailwindcss from '@tailwindcss/vite';`, "tailwindcss()");
|
|
821
|
+
}
|
|
822
|
+
if (css === "fluixi-css") {
|
|
823
|
+
addDeps(pkg, "dependencies", { "@fluixi-css/core": "next" });
|
|
824
|
+
addDeps(pkg, "devDependencies", { "@fluixi-css/vite": "next", lightningcss: "^1.29.3" });
|
|
825
|
+
addVitePlugin(
|
|
826
|
+
target,
|
|
827
|
+
mode,
|
|
828
|
+
`import fluixiCss from '@fluixi-css/vite';`,
|
|
829
|
+
// The bridge only matters with the component kit installed: it maps the theme
|
|
830
|
+
// scales onto the `--flx-ui-*` custom properties those components read.
|
|
831
|
+
`fluixiCss({ reset: true${ui === "fluixi-ui" ? ", emitUiTokens: true" : ""} })`
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
if (ui === "fluixi-ui" || css !== "none") {
|
|
835
|
+
if (css === "fluixi-css") writeFileSync3(join2(target, "src", "layers.css"), LAYERS_CSS);
|
|
836
|
+
const sheet = styleSheet(ui, css);
|
|
837
|
+
writeFileSync3(join2(target, "src", "styles.css"), sheet);
|
|
838
|
+
importStyles(target, mode, ui, css);
|
|
839
|
+
}
|
|
840
|
+
let authResult;
|
|
841
|
+
try {
|
|
842
|
+
if (auth === "oauth2") authResult = setupOAuth2(target, { provider, tokens, format });
|
|
843
|
+
else if (auth === "better-auth") authResult = setupBetterAuth(target);
|
|
844
|
+
} catch (error) {
|
|
845
|
+
if (error instanceof ScaffoldError) refuse(error.message);
|
|
846
|
+
throw error;
|
|
847
|
+
}
|
|
848
|
+
if (authResult) addDeps(pkg, "dependencies", authResult.dependencies);
|
|
849
|
+
writeFileSync3(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
850
|
+
const authTag = auth === "oauth2" ? `OAuth2 ${provider ?? "oidc"}` : auth === "better-auth" ? "Better Auth" : "";
|
|
851
|
+
const tag = `${c2.cyan(mode.toUpperCase())} ${c2.gray("\xB7")} ${c2.cyan(format === "html" ? "html``" : "JSX")}` + (authTag ? ` ${c2.gray("\xB7")} ${c2.cyan(authTag)}` : "");
|
|
852
|
+
if (interactive) output2.write(`${BAR2}
|
|
853
|
+
`);
|
|
854
|
+
else output2.write("\n");
|
|
855
|
+
output2.write(`${c2.green("\u25C7")} ${c2.green("Created")} ${c2.bold(name)} ${c2.gray("\xB7")} ${tag}
|
|
856
|
+
${c2.gray("\u2514")}
|
|
857
|
+
|
|
858
|
+
`);
|
|
859
|
+
output2.write(` ${c2.bold("Next")}
|
|
860
|
+
`);
|
|
861
|
+
output2.write(` ${c2.gray("\u203A")} cd ${dir}
|
|
862
|
+
`);
|
|
863
|
+
output2.write(` ${c2.gray("\u203A")} ${c2.cyan("pnpm install")} ${c2.gray("# or npm / yarn")}
|
|
864
|
+
`);
|
|
865
|
+
for (const step of authResult?.next ?? []) output2.write(` ${c2.gray("\u203A")} ${step}
|
|
866
|
+
`);
|
|
867
|
+
output2.write(` ${c2.gray("\u203A")} ${c2.cyan("pnpm dev")}
|
|
868
|
+
|
|
869
|
+
`);
|
|
870
|
+
for (const note of authResult?.notes ?? []) output2.write(` ${c2.gray(note)}
|
|
871
|
+
|
|
872
|
+
`);
|
|
404
873
|
}
|
|
405
874
|
main();
|