create-o2s-app 4.1.4 → 4.1.6

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,19 @@
1
1
  # create-o2s-app
2
2
 
3
+ ## 4.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - ff780e0: fix(cli): deduplicate npm dependencies during project scaffolding
8
+
9
+ ## 4.1.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 5ea13c5: fix: preserve private modules during project scaffolding
14
+
15
+ Previously, the CLI removed the entire `packages/modules` directory during scaffolding. Now only public (non-private) modules are removed, while private modules (e.g. `packages/modules/documents`) are kept as local workspace packages in the scaffolded project.
16
+
3
17
  ## 4.1.4
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -84,25 +84,10 @@ The `.env.local` file is generated automatically with all required environment v
84
84
 
85
85
  > **Note:** The scaffolded project does not have a git repository initialized. Run `git init` in the project directory to start tracking changes.
86
86
 
87
- ## Maintainers: `create-o2s-app/base` branch
88
-
89
- The CLI clones the **`create-o2s-app/base`** branch (see `src/constants.ts`). After publishing `@o2s/*` packages to npm, merge `main` into `create-o2s-app/base` and pin dependency versions in the starter apps.
90
-
91
- **`@o2s/framework` and `@o2s/integrations.mocked` are peer dependencies** of blocks, integrations, and `@o2s/configs.integrations`. They must **not** be duplicated as nested installs under `packages/configs/integrations` — the consuming apps (`apps/api-harmonization`, `apps/frontend`) already declare them as direct dependencies.
92
-
93
- When updating **`packages/configs/integrations`** on `create-o2s-app/base`, only install packages that remain **runtime dependencies** of that package (not peer-only). For example:
94
-
95
- ```shell
96
- cd packages/configs/integrations
97
- npm i @o2s/integrations.mocked-dxp@latest
98
- ```
99
-
100
- Do **not** run `npm i @o2s/framework@latest` or `npm i @o2s/integrations.mocked@latest` here for the purpose of “pinning” — those are **peer** dependencies; versions are pinned via **`apps/api-harmonization`** and **`apps/frontend`** (and Komendy 1–2 in your release checklist).
101
-
102
- **`@o2s/configs.integrations`** is a private workspace package — keep it as `"*"` in app `package.json` files so the workspace always resolves to the local copy.
103
-
104
87
  ## Related
105
88
 
106
89
  - [O2S Documentation](https://openselfservice.com/docs)
107
90
  - `@o2s/framework` — Core framework types and services
108
91
  - `@o2s/telemetry` — Anonymous usage telemetry
92
+
93
+ Scaffolded apps should keep **`@o2s/utils.frontend`** and **`@o2s/utils.api-harmonization`** as direct dependencies in `apps/frontend` and `apps/api-harmonization`. Blocks expect these from the app (peer dependencies), not from nested installs under each block.
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,eAAO,MAAM,eAAe,8CAA8C,CAAC;AAC3E,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,aAAa,+CAA+C,CAAC;AAC1E,eAAO,MAAM,QAAQ,sEAAsE,CAAC;AAC5F,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AAEzF,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAGzD,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAYtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAAoB,CAAC;AAE7D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiDzD,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,eAAO,MAAM,eAAe,8CAA8C,CAAC;AAC3E,eAAO,MAAM,aAAa,wBAAwB,CAAC;AACnD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,aAAa,+CAA+C,CAAC;AAC1E,eAAO,MAAM,QAAQ,sEAAsE,CAAC;AAC5F,eAAO,MAAM,qBAAqB,sDAAsD,CAAC;AAEzF,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAGzD,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAWtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAAoB,CAAC;AAE7D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiDzD,CAAC"}
package/dist/constants.js CHANGED
@@ -18,7 +18,6 @@ exports.ALWAYS_REMOVE_DIRS = [
18
18
  'packages/blocks',
19
19
  'packages/framework',
20
20
  'packages/integrations',
21
- 'packages/modules',
22
21
  'packages/utils',
23
22
  'packages/cli',
24
23
  'packages/telemetry',
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/scaffold/cleanup.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAgBrE,CAAC"}
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/scaffold/cleanup.ts"],"names":[],"mappings":"AAuCA,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAkBrE,CAAC"}
@@ -37,6 +37,34 @@ exports.cleanupProject = void 0;
37
37
  const constants_1 = require("../constants");
38
38
  const fs = __importStar(require("fs-extra"));
39
39
  const path = __importStar(require("path"));
40
+ /**
41
+ * Remove only public (non-private) packages from packages/modules/.
42
+ * Private modules are kept as local workspace packages in scaffolded projects.
43
+ */
44
+ const cleanupModules = async (projectDir) => {
45
+ const modulesDir = path.join(projectDir, 'packages', 'modules');
46
+ if (!(await fs.pathExists(modulesDir)))
47
+ return;
48
+ const entries = await fs.readdir(modulesDir, { withFileTypes: true });
49
+ for (const entry of entries) {
50
+ if (!entry.isDirectory())
51
+ continue;
52
+ const pkgJsonPath = path.join(modulesDir, entry.name, 'package.json');
53
+ if (!(await fs.pathExists(pkgJsonPath))) {
54
+ await fs.remove(path.join(modulesDir, entry.name));
55
+ continue;
56
+ }
57
+ const pkgJson = await fs.readJson(pkgJsonPath);
58
+ if (pkgJson.private !== true) {
59
+ await fs.remove(path.join(modulesDir, entry.name));
60
+ }
61
+ }
62
+ // Remove the modules directory itself if empty
63
+ const remaining = await fs.readdir(modulesDir);
64
+ if (remaining.length === 0) {
65
+ await fs.remove(modulesDir);
66
+ }
67
+ };
40
68
  const cleanupProject = async (projectDir) => {
41
69
  console.log('Organizing project structure...');
42
70
  for (const dir of constants_1.ALWAYS_REMOVE_DIRS) {
@@ -51,5 +79,6 @@ const cleanupProject = async (projectDir) => {
51
79
  await fs.remove(fullPath);
52
80
  }
53
81
  }
82
+ await cleanupModules(projectDir);
54
83
  };
55
84
  exports.cleanupProject = cleanupProject;
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/scaffold/install.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAU,YAAY,MAAM,EAAE,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAkDvG,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,YAAY,MAAM,EAAE,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAkB1G,CAAC"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/scaffold/install.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAU,YAAY,MAAM,EAAE,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAkDvG,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,YAAY,MAAM,EAAE,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAsB1G,CAAC"}
@@ -103,6 +103,10 @@ const installDependencies = async (projectDir, selectedIntegrations) => {
103
103
  cwd: projectDir,
104
104
  stdio: 'inherit',
105
105
  });
106
+ (0, child_process_1.execSync)('npm dedupe', {
107
+ cwd: projectDir,
108
+ stdio: 'inherit',
109
+ });
106
110
  console.log('Dependencies installed successfully.');
107
111
  }
108
112
  catch (error) {
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"transform-apps-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-apps-package-json.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,wBAAwB,GACjC,YAAY,MAAM,EAClB,oBAAoB,MAAM,EAAE,EAC5B,0BAA0B,MAAM,EAAE,KACnC,OAAO,CAAC,IAAI,CAgDd,CAAC"}
@@ -46,7 +46,31 @@ 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
+ };
49
72
  const transformAppsPackageJson = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
73
+ const privateModuleNames = await getPrivateModuleNames(projectDir);
50
74
  for (const relPath of APP_PACKAGE_JSON_PATHS) {
51
75
  const filePath = path.join(projectDir, relPath);
52
76
  if (!(await fs.pathExists(filePath)))
@@ -73,6 +97,12 @@ const transformAppsPackageJson = async (projectDir, selectedBlockNames, selected
73
97
  integrationMatch[1] &&
74
98
  !selectedIntegrationNames.includes(integrationMatch[1])) {
75
99
  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];
76
106
  }
77
107
  }
78
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transform-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-package-json.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAsB/E,CAAC"}
1
+ {"version":3,"file":"transform-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-package-json.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,wBAAwB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAiC/E,CAAC"}
@@ -36,14 +36,25 @@ 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 remove (their parent directories are deleted during cleanup)
40
- const REMOVED_WORKSPACE_GLOBS = ['packages/cli/*', 'packages/modules/*', 'packages/utils/*'];
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/*'];
41
43
  const transformRootPackageJson = async (projectDir) => {
42
44
  const filePath = path.join(projectDir, 'package.json');
43
45
  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];
44
55
  // Remove workspace entries for deleted directories
45
56
  if (Array.isArray(packageJson.workspaces)) {
46
- packageJson.workspaces = packageJson.workspaces.filter((ws) => !REMOVED_WORKSPACE_GLOBS.includes(ws));
57
+ packageJson.workspaces = packageJson.workspaces.filter((ws) => !allRemovedGlobs.includes(ws));
47
58
  }
48
59
  // Clean up scripts that reference removed directories
49
60
  if (packageJson.scripts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-o2s-app",
3
- "version": "4.1.4",
3
+ "version": "4.1.6",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "CLI tool to scaffold new O2S applications with Next.js and NestJS setup.",
package/src/constants.ts CHANGED
@@ -19,7 +19,6 @@ export const ALWAYS_REMOVE_DIRS: string[] = [
19
19
  'packages/blocks',
20
20
  'packages/framework',
21
21
  'packages/integrations',
22
- 'packages/modules',
23
22
  'packages/utils',
24
23
  'packages/cli',
25
24
  'packages/telemetry',
@@ -2,6 +2,41 @@ import { ALWAYS_REMOVE_DIRS, ALWAYS_REMOVE_FILES } from '../constants';
2
2
  import * as fs from 'fs-extra';
3
3
  import * as path from 'path';
4
4
 
5
+ /**
6
+ * Remove only public (non-private) packages from packages/modules/.
7
+ * Private modules are kept as local workspace packages in scaffolded projects.
8
+ */
9
+ const cleanupModules = async (projectDir: string): Promise<void> => {
10
+ const modulesDir = path.join(projectDir, 'packages', 'modules');
11
+
12
+ if (!(await fs.pathExists(modulesDir))) return;
13
+
14
+ const entries = await fs.readdir(modulesDir, { withFileTypes: true });
15
+
16
+ for (const entry of entries) {
17
+ if (!entry.isDirectory()) continue;
18
+
19
+ const pkgJsonPath = path.join(modulesDir, entry.name, 'package.json');
20
+
21
+ if (!(await fs.pathExists(pkgJsonPath))) {
22
+ await fs.remove(path.join(modulesDir, entry.name));
23
+ continue;
24
+ }
25
+
26
+ const pkgJson = await fs.readJson(pkgJsonPath);
27
+
28
+ if (pkgJson.private !== true) {
29
+ await fs.remove(path.join(modulesDir, entry.name));
30
+ }
31
+ }
32
+
33
+ // Remove the modules directory itself if empty
34
+ const remaining = await fs.readdir(modulesDir);
35
+ if (remaining.length === 0) {
36
+ await fs.remove(modulesDir);
37
+ }
38
+ };
39
+
5
40
  export const cleanupProject = async (projectDir: string): Promise<void> => {
6
41
  console.log('Organizing project structure...');
7
42
 
@@ -18,4 +53,6 @@ export const cleanupProject = async (projectDir: string): Promise<void> => {
18
53
  await fs.remove(fullPath);
19
54
  }
20
55
  }
56
+
57
+ await cleanupModules(projectDir);
21
58
  };
@@ -76,6 +76,10 @@ export const installDependencies = async (projectDir: string, selectedIntegratio
76
76
  cwd: projectDir,
77
77
  stdio: 'inherit',
78
78
  });
79
+ execSync('npm dedupe', {
80
+ cwd: projectDir,
81
+ stdio: 'inherit',
82
+ });
79
83
  console.log('Dependencies installed successfully.');
80
84
  } catch (error) {
81
85
  console.error('Error while installing dependencies.');
@@ -13,11 +13,41 @@ 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
+
16
44
  export const transformAppsPackageJson = async (
17
45
  projectDir: string,
18
46
  selectedBlockNames: string[],
19
47
  selectedIntegrationNames: string[],
20
48
  ): Promise<void> => {
49
+ const privateModuleNames = await getPrivateModuleNames(projectDir);
50
+
21
51
  for (const relPath of APP_PACKAGE_JSON_PATHS) {
22
52
  const filePath = path.join(projectDir, relPath);
23
53
 
@@ -50,6 +80,13 @@ export const transformAppsPackageJson = async (
50
80
  !selectedIntegrationNames.includes(integrationMatch[1])
51
81
  ) {
52
82
  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];
53
90
  }
54
91
  }
55
92
  }
@@ -1,16 +1,30 @@
1
1
  import * as fs from 'fs-extra';
2
2
  import * as path from 'path';
3
3
 
4
- // Workspace globs to remove (their parent directories are deleted during cleanup)
5
- const REMOVED_WORKSPACE_GLOBS = ['packages/cli/*', 'packages/modules/*', 'packages/utils/*'];
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/*'];
6
9
 
7
10
  export const transformRootPackageJson = async (projectDir: string): Promise<void> => {
8
11
  const filePath = path.join(projectDir, 'package.json');
9
12
  const packageJson = await fs.readJson(filePath);
10
13
 
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
+
11
25
  // Remove workspace entries for deleted directories
12
26
  if (Array.isArray(packageJson.workspaces)) {
13
- packageJson.workspaces = packageJson.workspaces.filter((ws: string) => !REMOVED_WORKSPACE_GLOBS.includes(ws));
27
+ packageJson.workspaces = packageJson.workspaces.filter((ws: string) => !allRemovedGlobs.includes(ws));
14
28
  }
15
29
 
16
30
  // Clean up scripts that reference removed directories