@farm.js/create-app 0.1.15 → 0.1.17
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 +26 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/_renderers/preact/package.json +3 -3
- package/templates/_renderers/solid/package.json +3 -3
- package/templates/_renderers/svelte/package.json +3 -3
- package/templates/_renderers/vue/package.json +4 -4
- package/templates/auth/package.json +4 -4
- package/templates/basic/package.json +3 -3
- package/templates/better-auth/package.json +4 -4
- package/templates/react-compiler/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2180,8 +2180,8 @@ better-auth.sqlite-wal
|
|
|
2180
2180
|
}
|
|
2181
2181
|
],
|
|
2182
2182
|
ui: betterAuthUIFeature(),
|
|
2183
|
-
template: () => `import { betterAuth } from "@farm.js/better-auth";
|
|
2184
|
-
import { auth } from "
|
|
2183
|
+
template: ({ importFrom }) => `import { betterAuth } from "@farm.js/better-auth";
|
|
2184
|
+
import { auth } from "${importFrom("src/lib/auth.ts")}";
|
|
2185
2185
|
|
|
2186
2186
|
export const betterAuthIntegration = betterAuth({
|
|
2187
2187
|
instance: auth,
|
|
@@ -2237,8 +2237,8 @@ export const auth = {
|
|
|
2237
2237
|
}],
|
|
2238
2238
|
notes: ["The generated Auth.js instance uses GitHub OAuth through @auth/core; add or replace providers in src/lib/auth.ts."],
|
|
2239
2239
|
ui: authjsUIFeature(),
|
|
2240
|
-
template: () => `import { authjs } from "@farm.js/authjs";
|
|
2241
|
-
import { auth } from "
|
|
2240
|
+
template: ({ importFrom }) => `import { authjs } from "@farm.js/authjs";
|
|
2241
|
+
import { auth } from "${importFrom("src/lib/auth.ts")}";
|
|
2242
2242
|
|
|
2243
2243
|
export const authjsIntegration = authjs({
|
|
2244
2244
|
instance: auth,
|
|
@@ -2356,6 +2356,7 @@ export const strapiIntegration = strapi({
|
|
|
2356
2356
|
async function addFarmIntegration(options) {
|
|
2357
2357
|
const root = path$1.resolve(options.root || process.cwd());
|
|
2358
2358
|
const definition = resolveProvider(options.provider);
|
|
2359
|
+
if (!options.skipPackageJson) await assertReadablePackageJson(root);
|
|
2359
2360
|
if (definition.provider === "ai") return addAIRouteIntegration({
|
|
2360
2361
|
root,
|
|
2361
2362
|
definition,
|
|
@@ -2382,6 +2383,7 @@ async function addFarmIntegration(options) {
|
|
|
2382
2383
|
notes: [...definition.notes || []]
|
|
2383
2384
|
};
|
|
2384
2385
|
await writeIntegrationComponent({
|
|
2386
|
+
root,
|
|
2385
2387
|
path: integrationFile,
|
|
2386
2388
|
definition,
|
|
2387
2389
|
force: options.force,
|
|
@@ -2443,6 +2445,7 @@ async function addAIRouteIntegration(input) {
|
|
|
2443
2445
|
notes: [...input.definition.notes || []]
|
|
2444
2446
|
};
|
|
2445
2447
|
await writeIntegrationComponent({
|
|
2448
|
+
root: input.root,
|
|
2446
2449
|
path: routeFile,
|
|
2447
2450
|
definition: input.definition,
|
|
2448
2451
|
force: input.force,
|
|
@@ -2486,7 +2489,8 @@ async function writeIntegrationComponent(input) {
|
|
|
2486
2489
|
}
|
|
2487
2490
|
if (!input.dryRun) {
|
|
2488
2491
|
await mkdir(path$1.dirname(input.path), { recursive: true });
|
|
2489
|
-
|
|
2492
|
+
const importFrom = (rootRelativePath) => toImportPath(path$1.relative(path$1.dirname(input.path), path$1.join(input.root, rootRelativePath)));
|
|
2493
|
+
await writeFile(input.path, input.definition.template({ importFrom }), "utf8");
|
|
2490
2494
|
}
|
|
2491
2495
|
if (exists) input.result.updated.push(input.path);
|
|
2492
2496
|
else input.result.created.push(input.path);
|
|
@@ -2565,14 +2569,29 @@ async function writeIntegrationSetupFiles(input) {
|
|
|
2565
2569
|
input.result[exists ? "updated" : "created"].push(absolutePath);
|
|
2566
2570
|
}
|
|
2567
2571
|
}
|
|
2572
|
+
async function readPackageManifest(packageJsonPath) {
|
|
2573
|
+
const source = await readFile(packageJsonPath, "utf8");
|
|
2574
|
+
try {
|
|
2575
|
+
return {
|
|
2576
|
+
source,
|
|
2577
|
+
manifest: JSON.parse(source)
|
|
2578
|
+
};
|
|
2579
|
+
} catch (error) {
|
|
2580
|
+
throw new Error(`Could not parse ${packageJsonPath}: ${error instanceof Error ? error.message : error}. Fix it, or pass --skip-package-json.`);
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
/** Fails before any file is written, so a broken package.json leaves the app untouched. */
|
|
2584
|
+
async function assertReadablePackageJson(root) {
|
|
2585
|
+
const packageJsonPath = path$1.join(root, "package.json");
|
|
2586
|
+
if (existsSync(packageJsonPath)) await readPackageManifest(packageJsonPath);
|
|
2587
|
+
}
|
|
2568
2588
|
async function updatePackageJson$1(input) {
|
|
2569
2589
|
const packageJsonPath = path$1.join(input.root, "package.json");
|
|
2570
2590
|
if (!existsSync(packageJsonPath)) {
|
|
2571
2591
|
input.result.skipped.push(packageJsonPath);
|
|
2572
2592
|
return;
|
|
2573
2593
|
}
|
|
2574
|
-
const source = await
|
|
2575
|
-
const manifest = JSON.parse(source);
|
|
2594
|
+
const { source, manifest } = await readPackageManifest(packageJsonPath);
|
|
2576
2595
|
const dependencies = missingDependencies(manifest, input.definition.dependencies);
|
|
2577
2596
|
const devDependencies = missingDependencies(manifest, input.definition.devDependencies);
|
|
2578
2597
|
manifest.dependencies = {
|