@jxsuite/create 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generate.ts +4 -27
- package/package.json +4 -3
package/generate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Shared project generation logic. Used by both the CLI scaffolder and the Studio server endpoint. */
|
|
2
2
|
|
|
3
3
|
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
|
+
import { adapterNeedsWrangler, buildWranglerJsonc } from "./scaffold";
|
|
4
5
|
import { basename, join, relative, sep } from "node:path";
|
|
5
6
|
|
|
6
7
|
import { Buffer } from "node:buffer";
|
|
@@ -49,8 +50,6 @@ export interface ProjectOptions {
|
|
|
49
50
|
design?: DesignOptions;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
const CF_ADAPTERS = new Set(["cloudflare-pages", "cloudflare-workers"]);
|
|
53
|
-
|
|
54
53
|
// Paths never copied out of a starter tree into a fresh project: build artifacts and the
|
|
55
54
|
// Authoring-only Pexels fetch manifest.
|
|
56
55
|
const STARTER_EXCLUDE = new Set([
|
|
@@ -117,7 +116,7 @@ export async function generateProject(destPath: string, opts: ProjectOptions) {
|
|
|
117
116
|
cp(join(TEMPLATE_DIR, "pages"), join(destPath, "pages"), { recursive: true }),
|
|
118
117
|
];
|
|
119
118
|
|
|
120
|
-
if (
|
|
119
|
+
if (adapterNeedsWrangler(adapter)) {
|
|
121
120
|
const wranglerJsonc = buildWranglerJsonc({ adapter, slug: packageJson.name });
|
|
122
121
|
writes.push(writeFile(join(destPath, "wrangler.jsonc"), wranglerJsonc));
|
|
123
122
|
}
|
|
@@ -198,7 +197,7 @@ async function scaffoldFromStarter(
|
|
|
198
197
|
const packageJson = buildPackageJson({ adapter, description, name });
|
|
199
198
|
await writeFile(join(destPath, "package.json"), `${JSON.stringify(packageJson, null, " ")}\n`);
|
|
200
199
|
|
|
201
|
-
if (
|
|
200
|
+
if (adapterNeedsWrangler(adapter)) {
|
|
202
201
|
const wranglerJsonc = buildWranglerJsonc({ adapter, slug: packageJson.name });
|
|
203
202
|
await writeFile(join(destPath, "wrangler.jsonc"), wranglerJsonc);
|
|
204
203
|
}
|
|
@@ -311,28 +310,6 @@ function applyDescription(project: Record<string, unknown>, description: string)
|
|
|
311
310
|
*
|
|
312
311
|
* @param {{ slug: string; adapter: string }} opts
|
|
313
312
|
*/
|
|
314
|
-
function buildWranglerJsonc({ slug, adapter }: { slug: string; adapter: string }) {
|
|
315
|
-
const compatibilityDate = new Date().toISOString().slice(0, 10);
|
|
316
|
-
|
|
317
|
-
// Nodejs_compat: server functions routinely pull in Node-flavored npm packages
|
|
318
|
-
const config =
|
|
319
|
-
adapter === "cloudflare-workers"
|
|
320
|
-
? {
|
|
321
|
-
assets: { binding: "ASSETS", directory: "./dist" },
|
|
322
|
-
compatibility_date: compatibilityDate,
|
|
323
|
-
compatibility_flags: ["nodejs_compat"],
|
|
324
|
-
main: "./dist/worker.js",
|
|
325
|
-
name: slug,
|
|
326
|
-
}
|
|
327
|
-
: {
|
|
328
|
-
compatibility_date: compatibilityDate,
|
|
329
|
-
compatibility_flags: ["nodejs_compat"],
|
|
330
|
-
name: slug,
|
|
331
|
-
pages_build_output_dir: "./dist",
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
return `${JSON.stringify(config, null, "\t")}\n`;
|
|
335
|
-
}
|
|
336
313
|
|
|
337
314
|
/** @param {ProjectOptions} opts */
|
|
338
315
|
function buildProjectJson({ name, description, url, adapter, template = "blank" }: ProjectOptions) {
|
|
@@ -425,7 +402,7 @@ function buildPackageJson({
|
|
|
425
402
|
dependencies["hono"] = "^4";
|
|
426
403
|
}
|
|
427
404
|
|
|
428
|
-
if (
|
|
405
|
+
if (adapterNeedsWrangler(adapter)) {
|
|
429
406
|
devDependencies["wrangler"] = "^4";
|
|
430
407
|
scripts.deploy =
|
|
431
408
|
adapter === "cloudflare-workers" ? "wrangler deploy" : "wrangler pages deploy dist";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/create",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Scaffold a new Jx project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": "./index.ts",
|
|
25
25
|
"./generate": "./generate.ts",
|
|
26
|
-
"./templates": "./templates.ts"
|
|
26
|
+
"./templates": "./templates.ts",
|
|
27
|
+
"./scaffold": "./scaffold.ts"
|
|
27
28
|
},
|
|
28
29
|
"publishConfig": {
|
|
29
30
|
"provenance": true
|
|
@@ -33,6 +34,6 @@
|
|
|
33
34
|
"test:coverage": "bun test --isolate --coverage"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@jxsuite/starters": "^0.35.
|
|
37
|
+
"@jxsuite/starters": "^0.35.1"
|
|
37
38
|
}
|
|
38
39
|
}
|