@jxsuite/create 1.5.4 → 1.6.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 +16 -10
- package/package.json +3 -2
- package/template-versions.json +4 -4
package/generate.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Shared project generation logic. Used by both the CLI scaffolder and the Studio server endpoint. */
|
|
2
2
|
|
|
3
3
|
import { chmod, cp, lstat, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
4
|
-
import { adapterNeedsWrangler, buildWranglerJsonc, isJsonObject
|
|
4
|
+
import { adapterNeedsWrangler, buildWranglerJsonc, isJsonObject } from "./scaffold";
|
|
5
5
|
import { basename, join, relative, sep } from "node:path";
|
|
6
6
|
|
|
7
7
|
import { Buffer } from "node:buffer";
|
|
@@ -12,6 +12,12 @@ import type { TemplateId } from "./templates";
|
|
|
12
12
|
import type { JsonObject } from "./scaffold";
|
|
13
13
|
|
|
14
14
|
import TEMPLATE_VERSIONS from "./template-versions.json";
|
|
15
|
+
import {
|
|
16
|
+
NEW_PROJECT_FILE_NAME,
|
|
17
|
+
parseProjectSource,
|
|
18
|
+
serializeProjectFile,
|
|
19
|
+
} from "@jxsuite/schema/project-file";
|
|
20
|
+
import { projectFilePath } from "@jxsuite/schema/project-file/node";
|
|
15
21
|
|
|
16
22
|
const __dirname = import.meta.dirname;
|
|
17
23
|
const TEMPLATE_DIR = join(__dirname, "template");
|
|
@@ -199,7 +205,7 @@ async function populateProject(destPath: string, opts: ProjectOptions) {
|
|
|
199
205
|
const packageJson = buildPackageJson({ adapter, description, name });
|
|
200
206
|
|
|
201
207
|
const writes = [
|
|
202
|
-
writeFile(join(destPath,
|
|
208
|
+
writeFile(join(destPath, NEW_PROJECT_FILE_NAME), serializeProjectFile(projectJson, null)),
|
|
203
209
|
writeFile(join(destPath, "package.json"), `${JSON.stringify(packageJson, null, " ")}\n`),
|
|
204
210
|
cp(join(TEMPLATE_DIR, "gitignore"), join(destPath, ".gitignore")),
|
|
205
211
|
cp(join(TEMPLATE_DIR, "layouts"), join(destPath, "layouts"), { recursive: true }),
|
|
@@ -271,13 +277,13 @@ async function scaffoldFromStarter(
|
|
|
271
277
|
// Before the re-stamp below, which writes straight back into the tree that was just copied.
|
|
272
278
|
await makeWritable(destPath);
|
|
273
279
|
|
|
274
|
-
// Re-stamp project
|
|
275
|
-
// Content types, image pipeline, and
|
|
276
|
-
const projectPath =
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
280
|
+
// Re-stamp the project file with the new project's identity, keeping the starter's design tokens,
|
|
281
|
+
// Content types, image pipeline, head, and in a project.jxn its comments.
|
|
282
|
+
const projectPath = projectFilePath(destPath);
|
|
283
|
+
const starterText = await readFile(projectPath, "utf8");
|
|
284
|
+
/* SAFETY: both readers answer an object, or throw (a starter whose project file is a list is
|
|
285
|
+
refused there, naming the file), and every member below is one the re-stamp owns. */
|
|
286
|
+
const project = parseProjectSource(starterText, projectPath) as JsonObject;
|
|
281
287
|
project.name = name;
|
|
282
288
|
if (url) {
|
|
283
289
|
project.url = url;
|
|
@@ -291,7 +297,7 @@ async function scaffoldFromStarter(
|
|
|
291
297
|
if (design) {
|
|
292
298
|
applyDesign(project, design, { starter: true });
|
|
293
299
|
}
|
|
294
|
-
await writeFile(projectPath,
|
|
300
|
+
await writeFile(projectPath, serializeProjectFile(project, starterText, projectPath));
|
|
295
301
|
|
|
296
302
|
// Rebuild package.json so scaffolded projects get current dep ranges and scripts regardless of
|
|
297
303
|
// What the in-repo starter pinned.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxsuite/create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Scaffold a new Jx project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"test:coverage": "bun test --isolate --coverage"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jxsuite/
|
|
40
|
+
"@jxsuite/schema": "^5.4.0",
|
|
41
|
+
"@jxsuite/starters": "^3.3.2"
|
|
41
42
|
}
|
|
42
43
|
}
|
package/template-versions.json
CHANGED