@postxl/generator 1.3.0 → 1.3.2

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.
@@ -17,6 +17,18 @@ function isPostXlWorkspacePackageName(packageName) {
17
17
  return !('version' in packageName) && packageName.packageName.startsWith('@postxl/');
18
18
  }
19
19
  function generatePackageJson({ dependencies, devDependencies, scripts, name, description, type: pType, isInPostXlWorkspace, }) {
20
+ const depsObject = dependencies.length > 0
21
+ ? dependencies
22
+ .map((dependency) => toDependency_Package({ dependency, isInPostXlWorkspace }))
23
+ .toSorted((a, b) => a.packageName.localeCompare(b.packageName))
24
+ .reduce((acc, dep) => ({ ...acc, [dep.packageName]: dep.version }), {})
25
+ : undefined;
26
+ const devDepsObject = devDependencies.length > 0
27
+ ? devDependencies
28
+ .map((dependency) => toDependency_Package({ dependency, isInPostXlWorkspace }))
29
+ .toSorted((a, b) => a.packageName.localeCompare(b.packageName))
30
+ .reduce((acc, dep) => ({ ...acc, [dep.packageName]: dep.version }), {})
31
+ : undefined;
20
32
  return JSON.stringify({
21
33
  name,
22
34
  version: '0.0.0',
@@ -29,14 +41,8 @@ function generatePackageJson({ dependencies, devDependencies, scripts, name, des
29
41
  .reduce((acc, script) => ({ ...acc, [script.name]: script.command }), {}),
30
42
  packageManager: `pnpm@${exports.PNPM_VERSION}`,
31
43
  devEngines: { runtime: { name: 'node', version: exports.NODE_VERSION, onFail: 'download' } },
32
- dependencies: dependencies
33
- .map((dependency) => toDependency_Package({ dependency, isInPostXlWorkspace }))
34
- .toSorted((a, b) => a.packageName.localeCompare(b.packageName))
35
- .reduce((acc, dep) => ({ ...acc, [dep.packageName]: dep.version }), {}),
36
- devDependencies: devDependencies
37
- .map((dependency) => toDependency_Package({ dependency, isInPostXlWorkspace }))
38
- .toSorted((a, b) => a.packageName.localeCompare(b.packageName))
39
- .reduce((acc, dep) => ({ ...acc, [dep.packageName]: dep.version }), {}),
44
+ ...(depsObject ? { dependencies: depsObject } : {}),
45
+ ...(devDepsObject ? { devDependencies: devDepsObject } : {}),
40
46
  license: 'UNLICENSED',
41
47
  });
42
48
  }
@@ -51,14 +51,26 @@ const parsers = {
51
51
  '.yml': 'yaml',
52
52
  '.css': 'css',
53
53
  };
54
+ /**
55
+ * Prettier config override for package.json files.
56
+ *
57
+ * Uses a smaller printWidth to ensure nested objects like `devEngines` are expanded
58
+ * across multiple lines. This matches pnpm's package.json formatting, which prevents
59
+ * formatting conflicts when running `pnpm install` after generation.
60
+ */
61
+ const packageJsonConfig = {
62
+ ...prettier_config_1.prettierConfig,
63
+ printWidth: 70,
64
+ };
54
65
  async function format({ path, content }) {
55
66
  const ext = (0, path_1.extname)(path);
56
67
  const parser = parsers[ext];
57
68
  if (parser === undefined || typeof content !== 'string') {
58
69
  return content;
59
70
  }
71
+ const config = (0, path_1.basename)(path) === 'package.json' ? packageJsonConfig : prettier_config_1.prettierConfig;
60
72
  try {
61
- return await prettier.format(content, { ...prettier_config_1.prettierConfig, parser });
73
+ return await prettier.format(content, { ...config, parser });
62
74
  }
63
75
  catch (err) {
64
76
  console.error(`${content}\n\nFailed to format ${path}\n\n`);
@@ -154,6 +154,9 @@ async function sync({ vfs, lockFilePath, diskFilePath, force }) {
154
154
  await Promise.all(tasks);
155
155
  return { success: true, ...result };
156
156
  }
157
+ const validFilesWithMergeConflictMarkers = new Set([
158
+ '/CLAUDE.md', // Contains instructions for resolving merge conflicts
159
+ ]);
157
160
  /**
158
161
  * Finds all files in the disk that contain unresolved merge conflict markers.
159
162
  *
@@ -163,7 +166,9 @@ async function sync({ vfs, lockFilePath, diskFilePath, force }) {
163
166
  function findFilesWithMergeConflicts(files) {
164
167
  const filesWithConflicts = [];
165
168
  for (const [filePath, { disk }] of files) {
166
- if (disk.state === 'hash' && (0, merge_conflict_1.hasMergeConflictMarkers)(disk.content)) {
169
+ if (disk.state === 'hash' &&
170
+ (0, merge_conflict_1.hasMergeConflictMarkers)(disk.content) &&
171
+ !validFilesWithMergeConflictMarkers.has(filePath)) {
167
172
  filesWithConflicts.push(filePath);
168
173
  }
169
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postxl/generator",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Core package that orchestrates the code generation of a PXL project",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",