create-o2s-app 4.1.7 → 4.1.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # create-o2s-app
2
2
 
3
+ ## 4.1.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 13257ce: update render block transformation by removing legacy regex handling
8
+
3
9
  ## 4.1.7
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"transform-render-blocks.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-render-blocks.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,qBAAqB,GAAU,YAAY,MAAM,EAAE,oBAAoB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAgE1G,CAAC"}
1
+ {"version":3,"file":"transform-render-blocks.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-render-blocks.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,qBAAqB,GAAU,YAAY,MAAM,EAAE,oBAAoB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAkD1G,CAAC"}
@@ -39,10 +39,8 @@ const path = __importStar(require("path"));
39
39
  const FILE_PATH = 'apps/frontend/src/blocks/renderBlocks.tsx';
40
40
  // Regex matches: import * as Alias from '@o2s/blocks.<name>/frontend';
41
41
  const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/frontend';$/;
42
- // Regex matches: case 'SomeBlock':
43
- const CASE_LINE_REGEX = /^\s+case '(\w+)':\s*$/;
44
- // Regex matches: return <Alias.Renderer (handles extra props like onSignOut, renderBlocks)
45
- const RETURN_RENDERER_REGEX = /^\s+return <(\w+)\.Renderer/;
42
+ // Regex matches: SomeBlock: (blockProps) => <Alias.Renderer ...
43
+ const REGISTRY_ENTRY_REGEX = /^\s+\w+:\s*\(blockProps\)\s*=>\s*<(\w+)\.Renderer/;
46
44
  const transformRenderBlocks = async (projectDir, selectedBlockNames) => {
47
45
  const filePath = path.join(projectDir, FILE_PATH);
48
46
  if (!(await fs.pathExists(filePath)))
@@ -66,14 +64,9 @@ const transformRenderBlocks = async (projectDir, selectedBlockNames) => {
66
64
  }
67
65
  if (aliasesToRemove.size === 0)
68
66
  return;
69
- // Process line by line — switch case/return pairs must be removed together
67
+ // Process line by line
70
68
  const result = [];
71
- let skipNext = false;
72
69
  for (let i = 0; i < lines.length; i++) {
73
- if (skipNext) {
74
- skipNext = false;
75
- continue;
76
- }
77
70
  const line = lines[i];
78
71
  if (line === undefined)
79
72
  continue;
@@ -82,18 +75,10 @@ const transformRenderBlocks = async (projectDir, selectedBlockNames) => {
82
75
  if (importMatch && importMatch[1] && aliasesToRemove.has(importMatch[1])) {
83
76
  continue;
84
77
  }
85
- // Detect switch case line and peek at the return line below it
86
- const caseMatch = line.match(CASE_LINE_REGEX);
87
- if (caseMatch && i + 1 < lines.length) {
88
- const nextLine = lines[i + 1];
89
- if (nextLine !== undefined) {
90
- const returnMatch = nextLine.match(RETURN_RENDERER_REGEX);
91
- if (returnMatch && returnMatch[1] && aliasesToRemove.has(returnMatch[1])) {
92
- // Skip both the case line (current) and the return line (next)
93
- skipNext = true;
94
- continue;
95
- }
96
- }
78
+ // Remove BLOCK_REGISTRY entries for unselected blocks
79
+ const registryMatch = line.match(REGISTRY_ENTRY_REGEX);
80
+ if (registryMatch && registryMatch[1] && aliasesToRemove.has(registryMatch[1])) {
81
+ continue;
97
82
  }
98
83
  result.push(line);
99
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-o2s-app",
3
- "version": "4.1.7",
3
+ "version": "4.1.8",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "CLI tool to scaffold new O2S applications with Next.js and NestJS setup.",
@@ -6,11 +6,8 @@ const FILE_PATH = 'apps/frontend/src/blocks/renderBlocks.tsx';
6
6
  // Regex matches: import * as Alias from '@o2s/blocks.<name>/frontend';
7
7
  const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/frontend';$/;
8
8
 
9
- // Regex matches: case 'SomeBlock':
10
- const CASE_LINE_REGEX = /^\s+case '(\w+)':\s*$/;
11
-
12
- // Regex matches: return <Alias.Renderer (handles extra props like onSignOut, renderBlocks)
13
- const RETURN_RENDERER_REGEX = /^\s+return <(\w+)\.Renderer/;
9
+ // Regex matches: SomeBlock: (blockProps) => <Alias.Renderer ...
10
+ const REGISTRY_ENTRY_REGEX = /^\s+\w+:\s*\(blockProps\)\s*=>\s*<(\w+)\.Renderer/;
14
11
 
15
12
  export const transformRenderBlocks = async (projectDir: string, selectedBlockNames: string[]): Promise<void> => {
16
13
  const filePath = path.join(projectDir, FILE_PATH);
@@ -39,16 +36,10 @@ export const transformRenderBlocks = async (projectDir: string, selectedBlockNam
39
36
 
40
37
  if (aliasesToRemove.size === 0) return;
41
38
 
42
- // Process line by line — switch case/return pairs must be removed together
39
+ // Process line by line
43
40
  const result: string[] = [];
44
- let skipNext = false;
45
41
 
46
42
  for (let i = 0; i < lines.length; i++) {
47
- if (skipNext) {
48
- skipNext = false;
49
- continue;
50
- }
51
-
52
43
  const line = lines[i];
53
44
  if (line === undefined) continue;
54
45
 
@@ -58,18 +49,10 @@ export const transformRenderBlocks = async (projectDir: string, selectedBlockNam
58
49
  continue;
59
50
  }
60
51
 
61
- // Detect switch case line and peek at the return line below it
62
- const caseMatch = line.match(CASE_LINE_REGEX);
63
- if (caseMatch && i + 1 < lines.length) {
64
- const nextLine = lines[i + 1];
65
- if (nextLine !== undefined) {
66
- const returnMatch = nextLine.match(RETURN_RENDERER_REGEX);
67
- if (returnMatch && returnMatch[1] && aliasesToRemove.has(returnMatch[1])) {
68
- // Skip both the case line (current) and the return line (next)
69
- skipNext = true;
70
- continue;
71
- }
72
- }
52
+ // Remove BLOCK_REGISTRY entries for unselected blocks
53
+ const registryMatch = line.match(REGISTRY_ENTRY_REGEX);
54
+ if (registryMatch && registryMatch[1] && aliasesToRemove.has(registryMatch[1])) {
55
+ continue;
73
56
  }
74
57
 
75
58
  result.push(line);