@jxsuite/create 1.5.5 → 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 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, parseJson } from "./scaffold";
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,7 +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 { PROJECT_FILE_NAME, serializeProjectFile } from "@jxsuite/schema/project-file";
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";
16
21
 
17
22
  const __dirname = import.meta.dirname;
18
23
  const TEMPLATE_DIR = join(__dirname, "template");
@@ -200,7 +205,7 @@ async function populateProject(destPath: string, opts: ProjectOptions) {
200
205
  const packageJson = buildPackageJson({ adapter, description, name });
201
206
 
202
207
  const writes = [
203
- writeFile(join(destPath, PROJECT_FILE_NAME), serializeProjectFile(projectJson, null)),
208
+ writeFile(join(destPath, NEW_PROJECT_FILE_NAME), serializeProjectFile(projectJson, null)),
204
209
  writeFile(join(destPath, "package.json"), `${JSON.stringify(packageJson, null, " ")}\n`),
205
210
  cp(join(TEMPLATE_DIR, "gitignore"), join(destPath, ".gitignore")),
206
211
  cp(join(TEMPLATE_DIR, "layouts"), join(destPath, "layouts"), { recursive: true }),
@@ -272,14 +277,13 @@ async function scaffoldFromStarter(
272
277
  // Before the re-stamp below, which writes straight back into the tree that was just copied.
273
278
  await makeWritable(destPath);
274
279
 
275
- // Re-stamp project.json with the new project's identity, keeping the starter's design tokens,
276
- // Content types, image pipeline, and head.
277
- const projectPath = join(destPath, PROJECT_FILE_NAME);
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);
278
283
  const starterText = await readFile(projectPath, "utf8");
279
- const project = parseJson(starterText);
280
- if (!isJsonObject(project)) {
281
- throw new TypeError(`Starter "${starter}" has a project.json that is not a JSON object`);
282
- }
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;
283
287
  project.name = name;
284
288
  if (url) {
285
289
  project.url = url;
@@ -293,7 +297,7 @@ async function scaffoldFromStarter(
293
297
  if (design) {
294
298
  applyDesign(project, design, { starter: true });
295
299
  }
296
- await writeFile(projectPath, serializeProjectFile(project, starterText));
300
+ await writeFile(projectPath, serializeProjectFile(project, starterText, projectPath));
297
301
 
298
302
  // Rebuild package.json so scaffolded projects get current dep ranges and scripts regardless of
299
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.5.5",
3
+ "version": "1.6.0",
4
4
  "description": "Scaffold a new Jx project",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "test:coverage": "bun test --isolate --coverage"
38
38
  },
39
39
  "dependencies": {
40
- "@jxsuite/schema": "^5.3.0",
41
- "@jxsuite/starters": "^3.3.1"
40
+ "@jxsuite/schema": "^5.4.0",
41
+ "@jxsuite/starters": "^3.3.2"
42
42
  }
43
43
  }
@@ -1,6 +1,6 @@
1
1
  {
2
- "parser": "^4.3.1",
3
- "compiler": "^8.3.0",
4
- "runtime": "^6.2.0",
5
- "server": "^8.4.0"
2
+ "parser": "^4.3.2",
3
+ "compiler": "^8.4.0",
4
+ "runtime": "^6.2.1",
5
+ "server": "^8.5.0"
6
6
  }