create-o2s-app 1.2.1 → 2.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +91 -0
  3. package/dist/constants.d.ts +12 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +73 -0
  6. package/dist/index.js +57 -89
  7. package/dist/scaffold/cleanup.d.ts +2 -0
  8. package/dist/scaffold/cleanup.d.ts.map +1 -0
  9. package/dist/scaffold/cleanup.js +86 -0
  10. package/dist/scaffold/clone.d.ts +3 -0
  11. package/dist/scaffold/clone.d.ts.map +1 -0
  12. package/dist/scaffold/clone.js +82 -0
  13. package/dist/scaffold/generate-env.d.ts +2 -0
  14. package/dist/scaffold/generate-env.d.ts.map +1 -0
  15. package/dist/scaffold/generate-env.js +68 -0
  16. package/dist/scaffold/index.d.ts +6 -0
  17. package/dist/scaffold/index.d.ts.map +1 -0
  18. package/dist/scaffold/index.js +83 -0
  19. package/dist/scaffold/install.d.ts +8 -0
  20. package/dist/scaffold/install.d.ts.map +1 -0
  21. package/dist/scaffold/install.js +79 -0
  22. package/dist/scaffold/transform-app-config.d.ts +2 -0
  23. package/dist/scaffold/transform-app-config.d.ts.map +1 -0
  24. package/dist/scaffold/transform-app-config.js +27 -0
  25. package/dist/scaffold/transform-app-module.d.ts +2 -0
  26. package/dist/scaffold/transform-app-module.d.ts.map +1 -0
  27. package/dist/scaffold/transform-app-module.js +78 -0
  28. package/dist/scaffold/transform-apps-package-json.d.ts +2 -0
  29. package/dist/scaffold/transform-apps-package-json.d.ts.map +1 -0
  30. package/dist/scaffold/transform-apps-package-json.js +64 -0
  31. package/dist/scaffold/transform-integration-configs.d.ts +3 -0
  32. package/dist/scaffold/transform-integration-configs.d.ts.map +1 -0
  33. package/dist/scaffold/transform-integration-configs.js +116 -0
  34. package/dist/scaffold/transform-package-json.d.ts +2 -0
  35. package/dist/scaffold/transform-package-json.d.ts.map +1 -0
  36. package/dist/scaffold/transform-package-json.js +61 -0
  37. package/dist/scaffold/transform-page-model.d.ts +2 -0
  38. package/dist/scaffold/transform-page-model.d.ts.map +1 -0
  39. package/dist/scaffold/transform-page-model.js +78 -0
  40. package/dist/scaffold/transform-render-blocks.d.ts +2 -0
  41. package/dist/scaffold/transform-render-blocks.d.ts.map +1 -0
  42. package/dist/scaffold/transform-render-blocks.js +102 -0
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/dist/types.d.ts +33 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/types.js +2 -0
  47. package/dist/utils/block-discovery.d.ts +3 -0
  48. package/dist/utils/block-discovery.d.ts.map +1 -0
  49. package/dist/utils/block-discovery.js +79 -0
  50. package/dist/utils/integration-discovery.d.ts +3 -0
  51. package/dist/utils/integration-discovery.d.ts.map +1 -0
  52. package/dist/utils/integration-discovery.js +79 -0
  53. package/dist/utils/logger.d.ts +4 -0
  54. package/dist/utils/logger.d.ts.map +1 -0
  55. package/dist/utils/logger.js +62 -0
  56. package/dist/wizard/env-prompts.d.ts +10 -0
  57. package/dist/wizard/env-prompts.d.ts.map +1 -0
  58. package/dist/wizard/env-prompts.js +66 -0
  59. package/dist/wizard/index.d.ts +3 -0
  60. package/dist/wizard/index.d.ts.map +1 -0
  61. package/dist/wizard/index.js +38 -0
  62. package/dist/wizard/prompts.d.ts +7 -0
  63. package/dist/wizard/prompts.d.ts.map +1 -0
  64. package/dist/wizard/prompts.js +106 -0
  65. package/dist/wizard/templates.d.ts +11 -0
  66. package/dist/wizard/templates.d.ts.map +1 -0
  67. package/dist/wizard/templates.js +47 -0
  68. package/package.json +25 -4
  69. package/src/constants.ts +76 -0
  70. package/src/index.ts +72 -106
  71. package/src/scaffold/cleanup.ts +63 -0
  72. package/src/scaffold/clone.ts +47 -0
  73. package/src/scaffold/generate-env.ts +44 -0
  74. package/src/scaffold/index.ts +69 -0
  75. package/src/scaffold/install.ts +47 -0
  76. package/src/scaffold/transform-app-config.ts +24 -0
  77. package/src/scaffold/transform-app-module.ts +50 -0
  78. package/src/scaffold/transform-apps-package-json.ts +39 -0
  79. package/src/scaffold/transform-integration-configs.ts +112 -0
  80. package/src/scaffold/transform-package-json.ts +29 -0
  81. package/src/scaffold/transform-page-model.ts +50 -0
  82. package/src/scaffold/transform-render-blocks.ts +79 -0
  83. package/src/types.ts +37 -0
  84. package/src/utils/block-discovery.ts +54 -0
  85. package/src/utils/integration-discovery.ts +58 -0
  86. package/src/utils/logger.ts +68 -0
  87. package/src/wizard/env-prompts.ts +83 -0
  88. package/src/wizard/index.ts +49 -0
  89. package/src/wizard/prompts.ts +119 -0
  90. package/src/wizard/templates.ts +61 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.scaffold = void 0;
37
+ const cleanup_1 = require("./cleanup");
38
+ const generate_env_1 = require("./generate-env");
39
+ const install_1 = require("./install");
40
+ const transform_app_config_1 = require("./transform-app-config");
41
+ const transform_app_module_1 = require("./transform-app-module");
42
+ const transform_apps_package_json_1 = require("./transform-apps-package-json");
43
+ const transform_integration_configs_1 = require("./transform-integration-configs");
44
+ const transform_package_json_1 = require("./transform-package-json");
45
+ const transform_page_model_1 = require("./transform-page-model");
46
+ const transform_render_blocks_1 = require("./transform-render-blocks");
47
+ const fs = __importStar(require("fs-extra"));
48
+ const path = __importStar(require("path"));
49
+ const scaffold = async (tempDir, answers, skipInstall = false, directory) => {
50
+ const targetDir = path.resolve(directory || '.', answers.projectName);
51
+ if (await fs.pathExists(targetDir)) {
52
+ throw new Error(`Directory "${answers.projectName}" already exists. Please choose a different name or remove the existing directory.`);
53
+ }
54
+ const { selectedBlocks, selectedIntegrations, integrationModules, conflictResolutions, envVars } = answers;
55
+ // Step 1: Move cloned repo to target directory
56
+ console.log();
57
+ console.log(`Creating project in "${targetDir}"...`);
58
+ 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
62
+ console.log('Configuring project for selected blocks...');
63
+ await Promise.all([
64
+ (0, transform_app_module_1.transformAppModule)(targetDir, selectedBlocks),
65
+ (0, transform_render_blocks_1.transformRenderBlocks)(targetDir, selectedBlocks),
66
+ (0, transform_page_model_1.transformPageModel)(targetDir, selectedBlocks),
67
+ (0, transform_apps_package_json_1.transformAppsPackageJson)(targetDir, selectedBlocks, selectedIntegrations),
68
+ ]);
69
+ // Step 4: Clean up root package.json (remove workspace entries for deleted dirs)
70
+ await (0, transform_package_json_1.transformRootPackageJson)(targetDir);
71
+ // Step 5: Configure integration source files and generate environment
72
+ console.log('Configuring integrations...');
73
+ const uncoveredModules = await (0, transform_integration_configs_1.transformIntegrationConfigs)(targetDir, selectedIntegrations, conflictResolutions, integrationModules);
74
+ await (0, generate_env_1.generateEnvFiles)(targetDir, envVars, selectedIntegrations);
75
+ (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);
78
+ if (!skipInstall) {
79
+ await (0, install_1.installDependencies)(targetDir);
80
+ }
81
+ return { targetDir, uncoveredModules };
82
+ };
83
+ exports.scaffold = scaffold;
@@ -0,0 +1,8 @@
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.
5
+ */
6
+ export declare const cleanPackageLock: (projectDir: string) => Promise<void>;
7
+ export declare const installDependencies: (projectDir: string) => Promise<void>;
8
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.installDependencies = exports.cleanPackageLock = void 0;
37
+ const child_process_1 = require("child_process");
38
+ const fs = __importStar(require("fs-extra"));
39
+ const path = __importStar(require("path"));
40
+ /**
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.
44
+ */
45
+ const cleanPackageLock = async (projectDir) => {
46
+ const lockFilePath = path.join(projectDir, 'package-lock.json');
47
+ if (!(await fs.pathExists(lockFilePath)))
48
+ return;
49
+ const file = await fs.readFile(lockFilePath, 'utf8');
50
+ const json = JSON.parse(file);
51
+ if (json?.packages) {
52
+ for (const [key, value] of Object.entries(json.packages)) {
53
+ if (value && typeof value === 'object' && value.link) {
54
+ delete json.packages[key];
55
+ }
56
+ }
57
+ }
58
+ await fs.writeFile(lockFilePath, JSON.stringify(json, null, 4));
59
+ };
60
+ exports.cleanPackageLock = cleanPackageLock;
61
+ const installDependencies = async (projectDir) => {
62
+ await (0, exports.cleanPackageLock)(projectDir);
63
+ console.log();
64
+ console.log('Installing dependencies...');
65
+ console.log();
66
+ try {
67
+ (0, child_process_1.execSync)('npm install', {
68
+ cwd: projectDir,
69
+ stdio: 'inherit',
70
+ });
71
+ console.log('Dependencies installed successfully.');
72
+ }
73
+ catch (error) {
74
+ console.error('Error while installing dependencies.');
75
+ console.error('You can try running "npm install" manually in the project directory.');
76
+ throw error;
77
+ }
78
+ };
79
+ exports.installDependencies = installDependencies;
@@ -0,0 +1,2 @@
1
+ export declare const warnUnconfiguredModules: (uncoveredModules: string[]) => void;
2
+ //# sourceMappingURL=transform-app-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-app-config.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-app-config.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,GAAI,kBAAkB,MAAM,EAAE,KAAG,IAiBpE,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.warnUnconfiguredModules = void 0;
7
+ const kleur_1 = __importDefault(require("kleur"));
8
+ // Warns about framework modules that have no integration configured.
9
+ // When mocked is not selected and a module has no real integration, the build
10
+ // will fail because the model file still imports from the deleted mocked package.
11
+ // Phase 3 will implement full app.config.ts transformation to remove unconfigured modules.
12
+ const warnUnconfiguredModules = (uncoveredModules) => {
13
+ if (uncoveredModules.length === 0) {
14
+ return;
15
+ }
16
+ console.warn();
17
+ console.warn(kleur_1.default.yellow().bold('Warning: The following framework modules have no integration configured:'));
18
+ for (const module of uncoveredModules) {
19
+ console.warn(kleur_1.default.yellow(` - ${module}`));
20
+ }
21
+ console.warn();
22
+ console.warn(kleur_1.default.red('These modules still reference @o2s/integrations.mocked which was not included in your project.'));
23
+ console.warn(kleur_1.default.red('The project build will fail until you configure these modules manually.'));
24
+ console.warn('To fix: update packages/configs/integrations/src/models/<module>.ts to use your integration.');
25
+ console.warn();
26
+ };
27
+ exports.warnUnconfiguredModules = warnUnconfiguredModules;
@@ -0,0 +1,2 @@
1
+ export declare const transformAppModule: (projectDir: string, selectedBlockNames: string[]) => Promise<void>;
2
+ //# sourceMappingURL=transform-app-module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-app-module.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-app-module.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kBAAkB,GAAU,YAAY,MAAM,EAAE,oBAAoB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAsCvG,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.transformAppModule = void 0;
37
+ const fs = __importStar(require("fs-extra"));
38
+ const path = __importStar(require("path"));
39
+ const FILE_PATH = 'apps/api-harmonization/src/app.module.ts';
40
+ // Regex matches: import * as Alias from '@o2s/blocks.<name>/api-harmonization';
41
+ const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/api-harmonization';$/;
42
+ // Regex matches: Alias.Module.register(AppConfig),
43
+ const BLOCK_REGISTRATION_REGEX = /^\s+(\w+)\.Module\.register\(AppConfig\),\s*$/;
44
+ const transformAppModule = async (projectDir, selectedBlockNames) => {
45
+ const filePath = path.join(projectDir, FILE_PATH);
46
+ if (!(await fs.pathExists(filePath)))
47
+ return;
48
+ const content = await fs.readFile(filePath, 'utf-8');
49
+ const lines = content.split('\n');
50
+ // Discover alias → blockName map from the actual file (handles special aliases)
51
+ const aliasToBlock = new Map();
52
+ for (const line of lines) {
53
+ const match = line.match(BLOCK_IMPORT_REGEX);
54
+ if (match && match[1] && match[2]) {
55
+ aliasToBlock.set(match[1], match[2]); // alias → blockName
56
+ }
57
+ }
58
+ // Build set of aliases for blocks the user did NOT select
59
+ const aliasesToRemove = new Set();
60
+ for (const [alias, blockName] of aliasToBlock.entries()) {
61
+ if (!selectedBlockNames.includes(blockName)) {
62
+ aliasesToRemove.add(alias);
63
+ }
64
+ }
65
+ if (aliasesToRemove.size === 0)
66
+ return;
67
+ const filteredLines = lines.filter((line) => {
68
+ const importMatch = line.match(BLOCK_IMPORT_REGEX);
69
+ if (importMatch && importMatch[1] && aliasesToRemove.has(importMatch[1]))
70
+ return false;
71
+ const regMatch = line.match(BLOCK_REGISTRATION_REGEX);
72
+ if (regMatch && regMatch[1] && aliasesToRemove.has(regMatch[1]))
73
+ return false;
74
+ return true;
75
+ });
76
+ await fs.writeFile(filePath, filteredLines.join('\n'), 'utf-8');
77
+ };
78
+ exports.transformAppModule = transformAppModule;
@@ -0,0 +1,2 @@
1
+ export declare const transformAppsPackageJson: (projectDir: string, selectedBlockNames: string[], selectedIntegrationNames: string[]) => Promise<void>;
2
+ //# sourceMappingURL=transform-apps-package-json.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.transformAppsPackageJson = void 0;
37
+ const fs = __importStar(require("fs-extra"));
38
+ const path = __importStar(require("path"));
39
+ const APP_PACKAGE_JSON_PATHS = ['apps/api-harmonization/package.json', 'apps/frontend/package.json'];
40
+ const transformAppsPackageJson = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
41
+ for (const relPath of APP_PACKAGE_JSON_PATHS) {
42
+ const filePath = path.join(projectDir, relPath);
43
+ if (!(await fs.pathExists(filePath)))
44
+ continue;
45
+ const packageJson = await fs.readJson(filePath);
46
+ if (packageJson.dependencies) {
47
+ for (const depName of Object.keys(packageJson.dependencies)) {
48
+ const blockMatch = depName.match(/^@o2s\/blocks\.(.+)$/);
49
+ if (blockMatch && blockMatch[1] && !selectedBlockNames.includes(blockMatch[1])) {
50
+ delete packageJson.dependencies[depName];
51
+ continue;
52
+ }
53
+ const integrationMatch = depName.match(/^@o2s\/integrations\.(.+)$/);
54
+ if (integrationMatch &&
55
+ integrationMatch[1] &&
56
+ !selectedIntegrationNames.includes(integrationMatch[1])) {
57
+ delete packageJson.dependencies[depName];
58
+ }
59
+ }
60
+ }
61
+ await fs.writeJson(filePath, packageJson, { spaces: 4 });
62
+ }
63
+ };
64
+ exports.transformAppsPackageJson = transformAppsPackageJson;
@@ -0,0 +1,3 @@
1
+ import { ConflictResolution } from '../types';
2
+ export declare const transformIntegrationConfigs: (projectDir: string, selectedIntegrations: string[], conflictResolutions: ConflictResolution[], integrationModules: Record<string, string[]>) => Promise<string[]>;
3
+ //# sourceMappingURL=transform-integration-configs.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.transformIntegrationConfigs = void 0;
37
+ const fs = __importStar(require("fs-extra"));
38
+ const path = __importStar(require("path"));
39
+ const CONFIGS_MODELS_PATH = 'packages/configs/integrations/src/models';
40
+ const CONFIGS_PACKAGE_JSON_PATH = 'packages/configs/integrations/package.json';
41
+ const MOCKED_IMPORT = `@o2s/integrations.mocked/integration`;
42
+ // Build a map from framework module name → winning integration.
43
+ // Integrations without o2sModules entries (e.g. mocked) contribute no modules.
44
+ const buildModuleIntegrationMap = (selectedIntegrations, conflictResolutions, integrationModules) => {
45
+ const moduleMap = new Map();
46
+ for (const integration of selectedIntegrations) {
47
+ const modules = integrationModules[integration] ?? [];
48
+ for (const module of modules) {
49
+ if (!moduleMap.has(module)) {
50
+ moduleMap.set(module, integration);
51
+ }
52
+ }
53
+ }
54
+ for (const resolution of conflictResolutions) {
55
+ moduleMap.set(resolution.module, resolution.winner);
56
+ }
57
+ return moduleMap;
58
+ };
59
+ const updateConfigsPackageJson = async (projectDir, selectedIntegrations, integrationModules) => {
60
+ const pkgPath = path.join(projectDir, CONFIGS_PACKAGE_JSON_PATH);
61
+ if (!(await fs.pathExists(pkgPath)))
62
+ return;
63
+ const pkg = await fs.readJson(pkgPath);
64
+ // Remove integration deps that were not selected
65
+ for (const key of Object.keys((pkg.dependencies || {}))) {
66
+ if (key.startsWith('@o2s/integrations.')) {
67
+ const name = key.replace('@o2s/integrations.', '');
68
+ if (!selectedIntegrations.includes(name)) {
69
+ delete pkg.dependencies[key];
70
+ }
71
+ }
72
+ }
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}`] = '*';
77
+ }
78
+ }
79
+ await fs.writeJson(pkgPath, pkg, { spaces: 4 });
80
+ };
81
+ const transformIntegrationConfigs = async (projectDir, selectedIntegrations, conflictResolutions, integrationModules) => {
82
+ const moduleMap = buildModuleIntegrationMap(selectedIntegrations, conflictResolutions, integrationModules);
83
+ if (moduleMap.size === 0) {
84
+ return [];
85
+ }
86
+ const modelsDir = path.join(projectDir, CONFIGS_MODELS_PATH);
87
+ if (!(await fs.pathExists(modelsDir))) {
88
+ return [];
89
+ }
90
+ for (const [module, integration] of moduleMap.entries()) {
91
+ const filePath = path.join(modelsDir, `${module}.ts`);
92
+ if (!(await fs.pathExists(filePath)))
93
+ continue;
94
+ const content = await fs.readFile(filePath, 'utf-8');
95
+ const updatedContent = content.replaceAll(MOCKED_IMPORT, `@o2s/integrations.${integration}/integration`);
96
+ await fs.writeFile(filePath, updatedContent, 'utf-8');
97
+ }
98
+ await updateConfigsPackageJson(projectDir, selectedIntegrations, integrationModules);
99
+ // Detect model files that still import mocked but mocked is not selected.
100
+ // Skip only when 'mocked' (full) is selected — it covers all modules.
101
+ // 'mocked-dxp' covers only cms/articles/search, so uncovered detection runs normally.
102
+ const uncoveredModules = [];
103
+ if (!selectedIntegrations.includes('mocked')) {
104
+ const files = await fs.readdir(modelsDir);
105
+ for (const file of files) {
106
+ if (file === 'index.ts' || !file.endsWith('.ts'))
107
+ continue;
108
+ const content = await fs.readFile(path.join(modelsDir, file), 'utf-8');
109
+ if (content.includes(MOCKED_IMPORT)) {
110
+ uncoveredModules.push(file.replace('.ts', ''));
111
+ }
112
+ }
113
+ }
114
+ return uncoveredModules;
115
+ };
116
+ exports.transformIntegrationConfigs = transformIntegrationConfigs;
@@ -0,0 +1,2 @@
1
+ export declare const transformRootPackageJson: (projectDir: string) => Promise<void>;
2
+ //# sourceMappingURL=transform-package-json.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.transformRootPackageJson = void 0;
37
+ const fs = __importStar(require("fs-extra"));
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/*'];
41
+ const transformRootPackageJson = async (projectDir) => {
42
+ const filePath = path.join(projectDir, 'package.json');
43
+ const packageJson = await fs.readJson(filePath);
44
+ // Remove workspace entries for deleted directories
45
+ if (Array.isArray(packageJson.workspaces)) {
46
+ packageJson.workspaces = packageJson.workspaces.filter((ws) => !REMOVED_WORKSPACE_GLOBS.includes(ws));
47
+ }
48
+ // Clean up scripts that reference removed directories
49
+ if (packageJson.scripts) {
50
+ for (const [key, value] of Object.entries(packageJson.scripts)) {
51
+ if (typeof value === 'string') {
52
+ // Remove turbo filter flags referencing packages/cli
53
+ packageJson.scripts[key] = value
54
+ .replace(/\s*-F=!\{\.\/packages\/cli\/\*\}/g, '')
55
+ .replace(/\s*-F=!\{\.\/packages\/telemetry\}/g, '');
56
+ }
57
+ }
58
+ }
59
+ await fs.writeJson(filePath, packageJson, { spaces: 4 });
60
+ };
61
+ exports.transformRootPackageJson = transformRootPackageJson;
@@ -0,0 +1,2 @@
1
+ export declare const transformPageModel: (projectDir: string, selectedBlockNames: string[]) => Promise<void>;
2
+ //# sourceMappingURL=transform-page-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-page-model.d.ts","sourceRoot":"","sources":["../../src/scaffold/transform-page-model.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kBAAkB,GAAU,YAAY,MAAM,EAAE,oBAAoB,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAsCvG,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.transformPageModel = void 0;
37
+ const fs = __importStar(require("fs-extra"));
38
+ const path = __importStar(require("path"));
39
+ const FILE_PATH = 'apps/api-harmonization/src/modules/page/page.model.ts';
40
+ // Regex matches: import * as Alias from '@o2s/blocks.<name>/api-harmonization';
41
+ const BLOCK_IMPORT_REGEX = /^import \* as (\w+) from '@o2s\/blocks\.([^/]+)\/api-harmonization';$/;
42
+ // Regex matches: | Alias.Model.SomeTypenameBlock['__typename']
43
+ const UNION_TYPE_REGEX = /^\s+\| (\w+)\.Model\.\w+\['__typename'\]/;
44
+ const transformPageModel = async (projectDir, selectedBlockNames) => {
45
+ const filePath = path.join(projectDir, FILE_PATH);
46
+ if (!(await fs.pathExists(filePath)))
47
+ return;
48
+ const content = await fs.readFile(filePath, 'utf-8');
49
+ const lines = content.split('\n');
50
+ // Discover alias → blockName map from the actual file
51
+ const aliasToBlock = new Map();
52
+ for (const line of lines) {
53
+ const match = line.match(BLOCK_IMPORT_REGEX);
54
+ if (match && match[1] && match[2]) {
55
+ aliasToBlock.set(match[1], match[2]); // alias → blockName
56
+ }
57
+ }
58
+ // Build set of aliases for blocks the user did NOT select
59
+ const aliasesToRemove = new Set();
60
+ for (const [alias, blockName] of aliasToBlock.entries()) {
61
+ if (!selectedBlockNames.includes(blockName)) {
62
+ aliasesToRemove.add(alias);
63
+ }
64
+ }
65
+ if (aliasesToRemove.size === 0)
66
+ return;
67
+ const filteredLines = lines.filter((line) => {
68
+ const importMatch = line.match(BLOCK_IMPORT_REGEX);
69
+ if (importMatch && importMatch[1] && aliasesToRemove.has(importMatch[1]))
70
+ return false;
71
+ const unionMatch = line.match(UNION_TYPE_REGEX);
72
+ if (unionMatch && unionMatch[1] && aliasesToRemove.has(unionMatch[1]))
73
+ return false;
74
+ return true;
75
+ });
76
+ await fs.writeFile(filePath, filteredLines.join('\n'), 'utf-8');
77
+ };
78
+ exports.transformPageModel = transformPageModel;
@@ -0,0 +1,2 @@
1
+ export declare const transformRenderBlocks: (projectDir: string, selectedBlockNames: string[]) => Promise<void>;
2
+ //# sourceMappingURL=transform-render-blocks.d.ts.map