create-o2s-app 2.0.0 → 4.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # create-o2s-app
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - a1659cf: added fix related to dxp starter and mocked data
8
+
9
+ ### Minor Changes
10
+
11
+ - a1659cf: fix: update CLI commands in logger to reflect new watch commands for development
12
+ - a1659cf: fix: update CLI custom installation process
13
+
14
+ ## 3.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - 1df1ec2: added fix related to dxp starter and mocked data
19
+
3
20
  ## 2.0.0
4
21
 
5
22
  ### Major Changes
package/README.md CHANGED
@@ -22,21 +22,21 @@ At the end, the wizard scaffolds your project and installs dependencies.
22
22
 
23
23
  ## Templates
24
24
 
25
- | Template | Description |
26
- |----------|-------------|
27
- | `o2s` | Full O2S Customer Portal — ticket management, invoices, notifications, orders and more |
28
- | `dxp` | DXP Frontend Starter — knowledge base, marketing portal, Digital Experience Platform |
29
- | `custom` | Start from scratch — choose only the blocks and integrations you need |
25
+ | Template | Description |
26
+ | -------- | -------------------------------------------------------------------------------------- |
27
+ | `o2s` | Full O2S Customer Portal — ticket management, invoices, notifications, orders and more |
28
+ | `dxp` | DXP Frontend Starter — knowledge base, marketing portal, Digital Experience Platform |
29
+ | `custom` | Start from scratch — choose only the blocks and integrations you need |
30
30
 
31
31
  ## Options
32
32
 
33
- | Option | Description |
34
- |--------|-------------|
35
- | `--template <template>` | Template to use: `o2s`, `dxp`, or `custom` |
36
- | `--blocks <blocks>` | Comma-separated list of block names (skips block selection prompt) |
33
+ | Option | Description |
34
+ | ------------------------------- | ------------------------------------------------------------------------------ |
35
+ | `--template <template>` | Template to use: `o2s`, `dxp`, or `custom` |
36
+ | `--blocks <blocks>` | Comma-separated list of block names (skips block selection prompt) |
37
37
  | `--integrations <integrations>` | Comma-separated list of integration names (skips integration selection prompt) |
38
- | `--skip-install` | Skip the `npm install` step |
39
- | `--directory <dir>` | Destination directory (defaults to project name) |
38
+ | `--skip-install` | Skip the `npm install` step |
39
+ | `--directory <dir>` | Destination directory (defaults to project name) |
40
40
 
41
41
  ## Non-Interactive Mode
42
42
 
@@ -44,18 +44,18 @@ Pass all required options as CLI flags to skip the interactive prompts:
44
44
 
45
45
  ```bash
46
46
  # Create an O2S portal with specific blocks and integrations
47
- npx create-o2s-app@latest my-portal \
47
+ npx create-o2s-app my-portal \
48
48
  --template o2s \
49
49
  --blocks ticket-list,invoice-list \
50
50
  --integrations zendesk,strapi-cms
51
51
 
52
52
  # Create a DXP starter, skip install
53
- npx create-o2s-app@latest my-dxp \
53
+ npx create-o2s-app my-dxp \
54
54
  --template dxp \
55
55
  --skip-install
56
56
 
57
57
  # Custom setup with only selected blocks
58
- npx create-o2s-app@latest my-custom \
58
+ npx create-o2s-app my-custom \
59
59
  --template custom \
60
60
  --blocks article-list,article-details \
61
61
  --integrations strapi-cms
@@ -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,qDAAqD,CAAC;AAE3E,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAC7C,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAGzD,eAAO,MAAM,kBAAkB,EAAE,MAAM,EAUtC,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,qDAAqD,CAAC;AAE3E,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"}
package/dist/constants.js CHANGED
@@ -14,7 +14,9 @@ exports.ALWAYS_REMOVE_DIRS = [
14
14
  '.github',
15
15
  '.changeset',
16
16
  'apps/docs',
17
+ 'packages/blocks',
17
18
  'packages/framework',
19
+ 'packages/integrations',
18
20
  'packages/modules',
19
21
  'packages/utils',
20
22
  'packages/cli',
@@ -1,2 +1,2 @@
1
- export declare const cleanupProject: (projectDir: string, selectedBlockNames: string[], selectedIntegrationNames: string[]) => Promise<void>;
1
+ export declare const cleanupProject: (projectDir: string) => Promise<void>;
2
2
  //# sourceMappingURL=cleanup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.d.ts","sourceRoot":"","sources":["../../src/scaffold/cleanup.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GACvB,YAAY,MAAM,EAClB,oBAAoB,MAAM,EAAE,EAC5B,0BAA0B,MAAM,EAAE,KACnC,OAAO,CAAC,IAAI,CAMd,CAAC"}
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"}
@@ -37,14 +37,8 @@ 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
- const cleanupProject = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
40
+ const cleanupProject = async (projectDir) => {
41
41
  console.log('Organizing project structure...');
42
- await removeAlwaysRemovedPaths(projectDir);
43
- await removeUnselectedBlocks(projectDir, selectedBlockNames);
44
- await removeUnselectedIntegrations(projectDir, selectedIntegrationNames);
45
- };
46
- exports.cleanupProject = cleanupProject;
47
- const removeAlwaysRemovedPaths = async (projectDir) => {
48
42
  for (const dir of constants_1.ALWAYS_REMOVE_DIRS) {
49
43
  const fullPath = path.join(projectDir, dir);
50
44
  if (await fs.pathExists(fullPath)) {
@@ -58,29 +52,4 @@ const removeAlwaysRemovedPaths = async (projectDir) => {
58
52
  }
59
53
  }
60
54
  };
61
- const removeUnselectedBlocks = async (projectDir, selectedBlockNames) => {
62
- const blocksDir = path.join(projectDir, constants_1.BLOCKS_PATH);
63
- if (!(await fs.pathExists(blocksDir)))
64
- return;
65
- const entries = await fs.readdir(blocksDir, { withFileTypes: true });
66
- for (const entry of entries) {
67
- if (!entry.isDirectory())
68
- continue;
69
- if (!selectedBlockNames.includes(entry.name)) {
70
- await fs.remove(path.join(blocksDir, entry.name));
71
- }
72
- }
73
- };
74
- const removeUnselectedIntegrations = async (projectDir, selectedIntegrationNames) => {
75
- const integrationsDir = path.join(projectDir, constants_1.INTEGRATIONS_PATH);
76
- if (!(await fs.pathExists(integrationsDir)))
77
- return;
78
- const entries = await fs.readdir(integrationsDir, { withFileTypes: true });
79
- for (const entry of entries) {
80
- if (!entry.isDirectory())
81
- continue;
82
- if (!selectedIntegrationNames.includes(entry.name)) {
83
- await fs.remove(path.join(integrationsDir, entry.name));
84
- }
85
- }
86
- };
55
+ exports.cleanupProject = cleanupProject;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAczC,eAAO,MAAM,QAAQ,GACjB,SAAS,MAAM,EACf,SAAS,aAAa,EACtB,qBAAmB,EACnB,YAAY,MAAM,KACnB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,CAiD3D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAyCzC,eAAO,MAAM,QAAQ,GACjB,SAAS,MAAM,EACf,SAAS,aAAa,EACtB,qBAAmB,EACnB,YAAY,MAAM,KACnB,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAAE,CAqD3D,CAAC"}
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.scaffold = void 0;
37
+ const constants_1 = require("../constants");
37
38
  const cleanup_1 = require("./cleanup");
38
39
  const generate_env_1 = require("./generate-env");
39
40
  const install_1 = require("./install");
@@ -46,6 +47,21 @@ const transform_page_model_1 = require("./transform-page-model");
46
47
  const transform_render_blocks_1 = require("./transform-render-blocks");
47
48
  const fs = __importStar(require("fs-extra"));
48
49
  const path = __importStar(require("path"));
50
+ const readIntegrationVersions = async (projectDir, selectedIntegrations) => {
51
+ const versions = {};
52
+ for (const name of selectedIntegrations) {
53
+ const pkgPath = path.join(projectDir, constants_1.INTEGRATIONS_PATH, name, 'package.json');
54
+ if (!(await fs.pathExists(pkgPath))) {
55
+ throw new Error(`Integration "${name}" not found at expected path: ${pkgPath}. Ensure the integration exists in the template.`);
56
+ }
57
+ const pkg = await fs.readJson(pkgPath);
58
+ if (!pkg.version) {
59
+ throw new Error(`Integration "${name}" has no version field in ${pkgPath}.`);
60
+ }
61
+ versions[name] = pkg.version;
62
+ }
63
+ return versions;
64
+ };
49
65
  const scaffold = async (tempDir, answers, skipInstall = false, directory) => {
50
66
  const targetDir = path.resolve(directory || '.', answers.projectName);
51
67
  if (await fs.pathExists(targetDir)) {
@@ -56,9 +72,11 @@ const scaffold = async (tempDir, answers, skipInstall = false, directory) => {
56
72
  console.log();
57
73
  console.log(`Creating project in "${targetDir}"...`);
58
74
  await fs.move(tempDir, targetDir);
59
- // Step 2: Remove unneeded directories
60
- await (0, cleanup_1.cleanupProject)(targetDir, selectedBlocks, selectedIntegrations);
61
- // Step 3: Remove unselected block/integration references from app source files
75
+ // Step 2: Read integration versions before cleanup removes the source directories
76
+ const integrationVersions = await readIntegrationVersions(targetDir, selectedIntegrations);
77
+ // Step 3: Remove unneeded directories (all packages/* are removed; deps come from npm registry)
78
+ await (0, cleanup_1.cleanupProject)(targetDir);
79
+ // Step 4: Remove unselected block/integration references from app source files
62
80
  console.log('Configuring project for selected blocks...');
63
81
  await Promise.all([
64
82
  (0, transform_app_module_1.transformAppModule)(targetDir, selectedBlocks),
@@ -66,17 +84,17 @@ const scaffold = async (tempDir, answers, skipInstall = false, directory) => {
66
84
  (0, transform_page_model_1.transformPageModel)(targetDir, selectedBlocks),
67
85
  (0, transform_apps_package_json_1.transformAppsPackageJson)(targetDir, selectedBlocks, selectedIntegrations),
68
86
  ]);
69
- // Step 4: Clean up root package.json (remove workspace entries for deleted dirs)
87
+ // Step 5: Clean up root package.json (remove workspace entries for deleted dirs)
70
88
  await (0, transform_package_json_1.transformRootPackageJson)(targetDir);
71
- // Step 5: Configure integration source files and generate environment
89
+ // Step 6: Configure integration source files and generate environment
72
90
  console.log('Configuring integrations...');
73
- const uncoveredModules = await (0, transform_integration_configs_1.transformIntegrationConfigs)(targetDir, selectedIntegrations, conflictResolutions, integrationModules);
91
+ const uncoveredModules = await (0, transform_integration_configs_1.transformIntegrationConfigs)(targetDir, selectedIntegrations, conflictResolutions, integrationModules, integrationVersions);
74
92
  await (0, generate_env_1.generateEnvFiles)(targetDir, envVars, selectedIntegrations);
75
93
  (0, transform_app_config_1.warnUnconfiguredModules)(uncoveredModules);
76
- // Step 6: Clean symlinks from package-lock.json and install dependencies
77
- await (0, install_1.cleanPackageLock)(targetDir);
94
+ // Step 7: Clean symlinks from package-lock.json and install dependencies
95
+ await (0, install_1.cleanPackageLock)(targetDir, selectedIntegrations);
78
96
  if (!skipInstall) {
79
- await (0, install_1.installDependencies)(targetDir);
97
+ await (0, install_1.installDependencies)(targetDir, selectedIntegrations);
80
98
  }
81
99
  return { targetDir, uncoveredModules };
82
100
  };
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Remove symlink entries ("link": true) from package-lock.json.
3
- * Without this, npm install would recreate empty folders for removed packages
4
- * (framework, integrations, blocks etc.) because the lock file still references them.
2
+ * Clean package-lock.json by removing:
3
+ * - Local workspace symlink entries ("link": true)
4
+ * - Entries for directories removed during cleanup (packages/blocks/*, packages/integrations/*, etc.)
5
+ * - References to unselected integrations in nested dependency lists
6
+ *
7
+ * Without this, npm install would either recreate empty folders for removed
8
+ * workspace packages or install unselected integrations from the registry.
5
9
  */
6
- export declare const cleanPackageLock: (projectDir: string) => Promise<void>;
7
- export declare const installDependencies: (projectDir: string) => Promise<void>;
10
+ export declare const cleanPackageLock: (projectDir: string, selectedIntegrations: string[]) => Promise<void>;
11
+ export declare const installDependencies: (projectDir: string, selectedIntegrations: string[]) => Promise<void>;
8
12
  //# sourceMappingURL=install.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/scaffold/install.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAiBvE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAkB1E,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,CAkB1G,CAAC"}
@@ -34,32 +34,67 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.installDependencies = exports.cleanPackageLock = void 0;
37
+ const constants_1 = require("../constants");
37
38
  const child_process_1 = require("child_process");
38
39
  const fs = __importStar(require("fs-extra"));
39
40
  const path = __importStar(require("path"));
40
41
  /**
41
- * Remove symlink entries ("link": true) from package-lock.json.
42
- * Without this, npm install would recreate empty folders for removed packages
43
- * (framework, integrations, blocks etc.) because the lock file still references them.
42
+ * Clean package-lock.json by removing:
43
+ * - Local workspace symlink entries ("link": true)
44
+ * - Entries for directories removed during cleanup (packages/blocks/*, packages/integrations/*, etc.)
45
+ * - References to unselected integrations in nested dependency lists
46
+ *
47
+ * Without this, npm install would either recreate empty folders for removed
48
+ * workspace packages or install unselected integrations from the registry.
44
49
  */
45
- const cleanPackageLock = async (projectDir) => {
50
+ const cleanPackageLock = async (projectDir, selectedIntegrations) => {
46
51
  const lockFilePath = path.join(projectDir, 'package-lock.json');
47
52
  if (!(await fs.pathExists(lockFilePath)))
48
53
  return;
49
54
  const file = await fs.readFile(lockFilePath, 'utf8');
50
55
  const json = JSON.parse(file);
56
+ const isUnselectedIntegration = (name) => {
57
+ const match = name.match(/^@o2s\/integrations\.(.+)$/);
58
+ return !!match && !!match[1] && !selectedIntegrations.includes(match[1]);
59
+ };
60
+ const isRemovedDir = (key) => {
61
+ return constants_1.ALWAYS_REMOVE_DIRS.some((dir) => key === dir || key.startsWith(`${dir}/`));
62
+ };
51
63
  if (json?.packages) {
52
64
  for (const [key, value] of Object.entries(json.packages)) {
53
- if (value && typeof value === 'object' && value.link) {
65
+ if (!value || typeof value !== 'object')
66
+ continue;
67
+ const entry = value;
68
+ // Remove local workspace symlinks
69
+ if (entry.link) {
54
70
  delete json.packages[key];
71
+ continue;
72
+ }
73
+ // Remove stale entries: deleted directories and workspace packages
74
+ // whose package.json was modified during scaffolding.
75
+ // npm install will regenerate correct entries from the actual files on disk.
76
+ if (isRemovedDir(key) || key.startsWith('packages/')) {
77
+ delete json.packages[key];
78
+ continue;
79
+ }
80
+ // Remove unselected integrations from nested dependencies
81
+ for (const section of ['dependencies', 'devDependencies']) {
82
+ const deps = entry[section];
83
+ if (!deps)
84
+ continue;
85
+ for (const depName of Object.keys(deps)) {
86
+ if (isUnselectedIntegration(depName)) {
87
+ delete deps[depName];
88
+ }
89
+ }
55
90
  }
56
91
  }
57
92
  }
58
93
  await fs.writeFile(lockFilePath, JSON.stringify(json, null, 4));
59
94
  };
60
95
  exports.cleanPackageLock = cleanPackageLock;
61
- const installDependencies = async (projectDir) => {
62
- await (0, exports.cleanPackageLock)(projectDir);
96
+ const installDependencies = async (projectDir, selectedIntegrations) => {
97
+ await (0, exports.cleanPackageLock)(projectDir, selectedIntegrations);
63
98
  console.log();
64
99
  console.log('Installing dependencies...');
65
100
  console.log();
@@ -1 +1 @@
1
- {"version":3,"file":"transform-apps-package-json.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-apps-package-json.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB,GACjC,YAAY,MAAM,EAClB,oBAAoB,MAAM,EAAE,EAC5B,0BAA0B,MAAM,EAAE,KACnC,OAAO,CAAC,IAAI,CA6Bd,CAAC"}
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"}
@@ -37,24 +37,42 @@ exports.transformAppsPackageJson = void 0;
37
37
  const fs = __importStar(require("fs-extra"));
38
38
  const path = __importStar(require("path"));
39
39
  const APP_PACKAGE_JSON_PATHS = ['apps/api-harmonization/package.json', 'apps/frontend/package.json'];
40
+ // Private workspace-only packages that are not published to npm and should be
41
+ // removed from scaffolded projects (they are part of the monorepo dev setup).
42
+ const PRIVATE_PACKAGES = [
43
+ '@o2s/eslint-config',
44
+ '@o2s/lint-staged-config',
45
+ '@o2s/prettier-config',
46
+ '@o2s/typescript-config',
47
+ '@o2s/vitest-config',
48
+ ];
40
49
  const transformAppsPackageJson = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
41
50
  for (const relPath of APP_PACKAGE_JSON_PATHS) {
42
51
  const filePath = path.join(projectDir, relPath);
43
52
  if (!(await fs.pathExists(filePath)))
44
53
  continue;
45
54
  const packageJson = await fs.readJson(filePath);
46
- if (packageJson.dependencies) {
47
- for (const depName of Object.keys(packageJson.dependencies)) {
55
+ for (const section of ['dependencies', 'devDependencies']) {
56
+ if (!packageJson[section])
57
+ continue;
58
+ for (const depName of Object.keys(packageJson[section])) {
59
+ // Remove private workspace-only packages
60
+ if (PRIVATE_PACKAGES.includes(depName)) {
61
+ delete packageJson[section][depName];
62
+ continue;
63
+ }
64
+ // Remove unselected blocks
48
65
  const blockMatch = depName.match(/^@o2s\/blocks\.(.+)$/);
49
66
  if (blockMatch && blockMatch[1] && !selectedBlockNames.includes(blockMatch[1])) {
50
- delete packageJson.dependencies[depName];
67
+ delete packageJson[section][depName];
51
68
  continue;
52
69
  }
70
+ // Remove unselected integrations
53
71
  const integrationMatch = depName.match(/^@o2s\/integrations\.(.+)$/);
54
72
  if (integrationMatch &&
55
73
  integrationMatch[1] &&
56
74
  !selectedIntegrationNames.includes(integrationMatch[1])) {
57
- delete packageJson.dependencies[depName];
75
+ delete packageJson[section][depName];
58
76
  }
59
77
  }
60
78
  }
@@ -1,3 +1,3 @@
1
1
  import { ConflictResolution } from '../types';
2
- export declare const transformIntegrationConfigs: (projectDir: string, selectedIntegrations: string[], conflictResolutions: ConflictResolution[], integrationModules: Record<string, string[]>) => Promise<string[]>;
2
+ export declare const transformIntegrationConfigs: (projectDir: string, selectedIntegrations: string[], conflictResolutions: ConflictResolution[], integrationModules: Record<string, string[]>, integrationVersions: Record<string, string>) => Promise<string[]>;
3
3
  //# sourceMappingURL=transform-integration-configs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transform-integration-configs.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-integration-configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgE9C,eAAO,MAAM,2BAA2B,GACpC,YAAY,MAAM,EAClB,sBAAsB,MAAM,EAAE,EAC9B,qBAAqB,kBAAkB,EAAE,EACzC,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAC7C,OAAO,CAAC,MAAM,EAAE,CA0ClB,CAAC"}
1
+ {"version":3,"file":"transform-integration-configs.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-integration-configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAwE9C,eAAO,MAAM,2BAA2B,GACpC,YAAY,MAAM,EAClB,sBAAsB,MAAM,EAAE,EAC9B,qBAAqB,kBAAkB,EAAE,EACzC,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC5C,qBAAqB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC5C,OAAO,CAAC,MAAM,EAAE,CAwClB,CAAC"}
@@ -56,13 +56,16 @@ const buildModuleIntegrationMap = (selectedIntegrations, conflictResolutions, in
56
56
  }
57
57
  return moduleMap;
58
58
  };
59
- const updateConfigsPackageJson = async (projectDir, selectedIntegrations, integrationModules) => {
59
+ const updateConfigsPackageJson = async (projectDir, selectedIntegrations, integrationVersions) => {
60
60
  const pkgPath = path.join(projectDir, CONFIGS_PACKAGE_JSON_PATH);
61
61
  if (!(await fs.pathExists(pkgPath)))
62
62
  return;
63
63
  const pkg = await fs.readJson(pkgPath);
64
+ if (!pkg.dependencies) {
65
+ pkg.dependencies = {};
66
+ }
64
67
  // Remove integration deps that were not selected
65
- for (const key of Object.keys((pkg.dependencies || {}))) {
68
+ for (const key of Object.keys(pkg.dependencies)) {
66
69
  if (key.startsWith('@o2s/integrations.')) {
67
70
  const name = key.replace('@o2s/integrations.', '');
68
71
  if (!selectedIntegrations.includes(name)) {
@@ -70,23 +73,27 @@ const updateConfigsPackageJson = async (projectDir, selectedIntegrations, integr
70
73
  }
71
74
  }
72
75
  }
73
- // Add deps for selected integrations that have module mappings
74
- for (const integration of selectedIntegrations) {
75
- if (integrationModules[integration]?.length) {
76
- pkg.dependencies[`@o2s/integrations.${integration}`] = '*';
76
+ // Add selected integrations that are not yet in dependencies
77
+ for (const name of selectedIntegrations) {
78
+ const packageName = `@o2s/integrations.${name}`;
79
+ if (!pkg.dependencies[packageName]) {
80
+ const version = integrationVersions[name];
81
+ if (version) {
82
+ pkg.dependencies[packageName] = `^${version}`;
83
+ }
77
84
  }
78
85
  }
79
86
  await fs.writeJson(pkgPath, pkg, { spaces: 4 });
80
87
  };
81
- const transformIntegrationConfigs = async (projectDir, selectedIntegrations, conflictResolutions, integrationModules) => {
82
- const moduleMap = buildModuleIntegrationMap(selectedIntegrations, conflictResolutions, integrationModules);
83
- if (moduleMap.size === 0) {
84
- return [];
85
- }
88
+ const transformIntegrationConfigs = async (projectDir, selectedIntegrations, conflictResolutions, integrationModules, integrationVersions) => {
89
+ // Always update configs package.json to add/remove integration dependencies
90
+ await updateConfigsPackageJson(projectDir, selectedIntegrations, integrationVersions);
86
91
  const modelsDir = path.join(projectDir, CONFIGS_MODELS_PATH);
87
92
  if (!(await fs.pathExists(modelsDir))) {
88
93
  return [];
89
94
  }
95
+ // Replace mocked imports with selected integration imports
96
+ const moduleMap = buildModuleIntegrationMap(selectedIntegrations, conflictResolutions, integrationModules);
90
97
  for (const [module, integration] of moduleMap.entries()) {
91
98
  const filePath = path.join(modelsDir, `${module}.ts`);
92
99
  if (!(await fs.pathExists(filePath)))
@@ -95,7 +102,6 @@ const transformIntegrationConfigs = async (projectDir, selectedIntegrations, con
95
102
  const updatedContent = content.replaceAll(MOCKED_IMPORT, `@o2s/integrations.${integration}/integration`);
96
103
  await fs.writeFile(filePath, updatedContent, 'utf-8');
97
104
  }
98
- await updateConfigsPackageJson(projectDir, selectedIntegrations, integrationModules);
99
105
  // Detect model files that still import mocked but mocked is not selected.
100
106
  // Skip only when 'mocked' (full) is selected — it covers all modules.
101
107
  // 'mocked-dxp' covers only cms/articles/search, so uncovered detection runs normally.