create-o2s-app 4.1.6 → 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 +12 -0
- package/dist/scaffold/transform-apps-package-json.d.ts.map +1 -1
- package/dist/scaffold/transform-apps-package-json.js +0 -30
- package/dist/scaffold/transform-package-json.d.ts.map +1 -1
- package/dist/scaffold/transform-package-json.js +0 -17
- package/dist/scaffold/transform-render-blocks.d.ts.map +1 -1
- package/dist/scaffold/transform-render-blocks.js +7 -22
- package/package.json +1 -1
- package/src/scaffold/transform-apps-package-json.ts +0 -37
- package/src/scaffold/transform-package-json.ts +0 -22
- package/src/scaffold/transform-render-blocks.ts +7 -24
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
9
|
+
## 4.1.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3ff35ec: remove unused logic for handling private modules during scaffolding
|
|
14
|
+
|
|
3
15
|
## 4.1.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-apps-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-apps-package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-apps-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-apps-package-json.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,wBAAwB,GACjC,YAAY,MAAM,EAClB,oBAAoB,MAAM,EAAE,EAC5B,0BAA0B,MAAM,EAAE,KACnC,OAAO,CAAC,IAAI,CAuCd,CAAC"}
|
|
@@ -46,31 +46,7 @@ const PRIVATE_PACKAGES = [
|
|
|
46
46
|
'@o2s/typescript-config',
|
|
47
47
|
'@o2s/vitest-config',
|
|
48
48
|
];
|
|
49
|
-
/**
|
|
50
|
-
* Collect the names of private modules that still exist in the scaffolded project.
|
|
51
|
-
* Public modules are removed during cleanup, so anything still present is private.
|
|
52
|
-
*/
|
|
53
|
-
const getPrivateModuleNames = async (projectDir) => {
|
|
54
|
-
const modulesDir = path.join(projectDir, 'packages', 'modules');
|
|
55
|
-
const names = new Set();
|
|
56
|
-
if (!(await fs.pathExists(modulesDir)))
|
|
57
|
-
return names;
|
|
58
|
-
const entries = await fs.readdir(modulesDir, { withFileTypes: true });
|
|
59
|
-
for (const entry of entries) {
|
|
60
|
-
if (!entry.isDirectory())
|
|
61
|
-
continue;
|
|
62
|
-
const pkgJsonPath = path.join(modulesDir, entry.name, 'package.json');
|
|
63
|
-
if (await fs.pathExists(pkgJsonPath)) {
|
|
64
|
-
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
65
|
-
if (pkgJson.name) {
|
|
66
|
-
names.add(pkgJson.name);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return names;
|
|
71
|
-
};
|
|
72
49
|
const transformAppsPackageJson = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
|
|
73
|
-
const privateModuleNames = await getPrivateModuleNames(projectDir);
|
|
74
50
|
for (const relPath of APP_PACKAGE_JSON_PATHS) {
|
|
75
51
|
const filePath = path.join(projectDir, relPath);
|
|
76
52
|
if (!(await fs.pathExists(filePath)))
|
|
@@ -97,12 +73,6 @@ const transformAppsPackageJson = async (projectDir, selectedBlockNames, selected
|
|
|
97
73
|
integrationMatch[1] &&
|
|
98
74
|
!selectedIntegrationNames.includes(integrationMatch[1])) {
|
|
99
75
|
delete packageJson[section][depName];
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
// Remove public (non-private) module dependencies — they are installed from npm
|
|
103
|
-
const moduleMatch = depName.match(/^@o2s\/modules\..+$/);
|
|
104
|
-
if (moduleMatch && !privateModuleNames.has(depName)) {
|
|
105
|
-
delete packageJson[section][depName];
|
|
106
76
|
}
|
|
107
77
|
}
|
|
108
78
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-package-json.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAiB/E,CAAC"}
|
|
@@ -36,26 +36,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.transformRootPackageJson = void 0;
|
|
37
37
|
const fs = __importStar(require("fs-extra"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
|
-
// Workspace globs to always remove (their parent directories are deleted during cleanup)
|
|
40
|
-
const REMOVED_WORKSPACE_GLOBS = ['packages/cli/*', 'packages/utils/*'];
|
|
41
|
-
// Workspace globs to remove only when the directory is empty after cleanup
|
|
42
|
-
const CONDITIONAL_WORKSPACE_GLOBS = ['packages/modules/*'];
|
|
43
39
|
const transformRootPackageJson = async (projectDir) => {
|
|
44
40
|
const filePath = path.join(projectDir, 'package.json');
|
|
45
41
|
const packageJson = await fs.readJson(filePath);
|
|
46
|
-
// Check which conditional globs still have content
|
|
47
|
-
const emptyConditionalGlobs = [];
|
|
48
|
-
for (const glob of CONDITIONAL_WORKSPACE_GLOBS) {
|
|
49
|
-
const dir = path.join(projectDir, glob.replace('/*', ''));
|
|
50
|
-
if (!(await fs.pathExists(dir))) {
|
|
51
|
-
emptyConditionalGlobs.push(glob);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
const allRemovedGlobs = [...REMOVED_WORKSPACE_GLOBS, ...emptyConditionalGlobs];
|
|
55
|
-
// Remove workspace entries for deleted directories
|
|
56
|
-
if (Array.isArray(packageJson.workspaces)) {
|
|
57
|
-
packageJson.workspaces = packageJson.workspaces.filter((ws) => !allRemovedGlobs.includes(ws));
|
|
58
|
-
}
|
|
59
42
|
// Clean up scripts that reference removed directories
|
|
60
43
|
if (packageJson.scripts) {
|
|
61
44
|
for (const [key, value] of Object.entries(packageJson.scripts)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-render-blocks.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-render-blocks.ts"],"names":[],"mappings":"
|
|
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:
|
|
43
|
-
const
|
|
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
|
|
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
|
-
//
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
|
|
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
|
@@ -13,41 +13,11 @@ const PRIVATE_PACKAGES = [
|
|
|
13
13
|
'@o2s/vitest-config',
|
|
14
14
|
];
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* Collect the names of private modules that still exist in the scaffolded project.
|
|
18
|
-
* Public modules are removed during cleanup, so anything still present is private.
|
|
19
|
-
*/
|
|
20
|
-
const getPrivateModuleNames = async (projectDir: string): Promise<Set<string>> => {
|
|
21
|
-
const modulesDir = path.join(projectDir, 'packages', 'modules');
|
|
22
|
-
const names = new Set<string>();
|
|
23
|
-
|
|
24
|
-
if (!(await fs.pathExists(modulesDir))) return names;
|
|
25
|
-
|
|
26
|
-
const entries = await fs.readdir(modulesDir, { withFileTypes: true });
|
|
27
|
-
|
|
28
|
-
for (const entry of entries) {
|
|
29
|
-
if (!entry.isDirectory()) continue;
|
|
30
|
-
|
|
31
|
-
const pkgJsonPath = path.join(modulesDir, entry.name, 'package.json');
|
|
32
|
-
|
|
33
|
-
if (await fs.pathExists(pkgJsonPath)) {
|
|
34
|
-
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
35
|
-
if (pkgJson.name) {
|
|
36
|
-
names.add(pkgJson.name);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return names;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
16
|
export const transformAppsPackageJson = async (
|
|
45
17
|
projectDir: string,
|
|
46
18
|
selectedBlockNames: string[],
|
|
47
19
|
selectedIntegrationNames: string[],
|
|
48
20
|
): Promise<void> => {
|
|
49
|
-
const privateModuleNames = await getPrivateModuleNames(projectDir);
|
|
50
|
-
|
|
51
21
|
for (const relPath of APP_PACKAGE_JSON_PATHS) {
|
|
52
22
|
const filePath = path.join(projectDir, relPath);
|
|
53
23
|
|
|
@@ -80,13 +50,6 @@ export const transformAppsPackageJson = async (
|
|
|
80
50
|
!selectedIntegrationNames.includes(integrationMatch[1])
|
|
81
51
|
) {
|
|
82
52
|
delete packageJson[section][depName];
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Remove public (non-private) module dependencies — they are installed from npm
|
|
87
|
-
const moduleMatch = depName.match(/^@o2s\/modules\..+$/);
|
|
88
|
-
if (moduleMatch && !privateModuleNames.has(depName)) {
|
|
89
|
-
delete packageJson[section][depName];
|
|
90
53
|
}
|
|
91
54
|
}
|
|
92
55
|
}
|
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
import * as fs from 'fs-extra';
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
|
|
4
|
-
// Workspace globs to always remove (their parent directories are deleted during cleanup)
|
|
5
|
-
const REMOVED_WORKSPACE_GLOBS = ['packages/cli/*', 'packages/utils/*'];
|
|
6
|
-
|
|
7
|
-
// Workspace globs to remove only when the directory is empty after cleanup
|
|
8
|
-
const CONDITIONAL_WORKSPACE_GLOBS = ['packages/modules/*'];
|
|
9
|
-
|
|
10
4
|
export const transformRootPackageJson = async (projectDir: string): Promise<void> => {
|
|
11
5
|
const filePath = path.join(projectDir, 'package.json');
|
|
12
6
|
const packageJson = await fs.readJson(filePath);
|
|
13
7
|
|
|
14
|
-
// Check which conditional globs still have content
|
|
15
|
-
const emptyConditionalGlobs: string[] = [];
|
|
16
|
-
for (const glob of CONDITIONAL_WORKSPACE_GLOBS) {
|
|
17
|
-
const dir = path.join(projectDir, glob.replace('/*', ''));
|
|
18
|
-
if (!(await fs.pathExists(dir))) {
|
|
19
|
-
emptyConditionalGlobs.push(glob);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const allRemovedGlobs = [...REMOVED_WORKSPACE_GLOBS, ...emptyConditionalGlobs];
|
|
24
|
-
|
|
25
|
-
// Remove workspace entries for deleted directories
|
|
26
|
-
if (Array.isArray(packageJson.workspaces)) {
|
|
27
|
-
packageJson.workspaces = packageJson.workspaces.filter((ws: string) => !allRemovedGlobs.includes(ws));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
8
|
// Clean up scripts that reference removed directories
|
|
31
9
|
if (packageJson.scripts) {
|
|
32
10
|
for (const [key, value] of Object.entries(packageJson.scripts)) {
|
|
@@ -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:
|
|
10
|
-
const
|
|
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
|
|
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
|
-
//
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
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);
|