create-o2s-app 1.2.1 → 3.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 +27 -0
- package/README.md +91 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +75 -0
- package/dist/index.js +57 -89
- package/dist/scaffold/cleanup.d.ts +2 -0
- package/dist/scaffold/cleanup.d.ts.map +1 -0
- package/dist/scaffold/cleanup.js +55 -0
- package/dist/scaffold/clone.d.ts +3 -0
- package/dist/scaffold/clone.d.ts.map +1 -0
- package/dist/scaffold/clone.js +82 -0
- package/dist/scaffold/generate-env.d.ts +2 -0
- package/dist/scaffold/generate-env.d.ts.map +1 -0
- package/dist/scaffold/generate-env.js +68 -0
- package/dist/scaffold/index.d.ts +6 -0
- package/dist/scaffold/index.d.ts.map +1 -0
- package/dist/scaffold/index.js +83 -0
- package/dist/scaffold/install.d.ts +8 -0
- package/dist/scaffold/install.d.ts.map +1 -0
- package/dist/scaffold/install.js +79 -0
- package/dist/scaffold/transform-app-config.d.ts +2 -0
- package/dist/scaffold/transform-app-config.d.ts.map +1 -0
- package/dist/scaffold/transform-app-config.js +27 -0
- package/dist/scaffold/transform-app-module.d.ts +2 -0
- package/dist/scaffold/transform-app-module.d.ts.map +1 -0
- package/dist/scaffold/transform-app-module.js +78 -0
- package/dist/scaffold/transform-apps-package-json.d.ts +2 -0
- package/dist/scaffold/transform-apps-package-json.d.ts.map +1 -0
- package/dist/scaffold/transform-apps-package-json.js +82 -0
- package/dist/scaffold/transform-integration-configs.d.ts +3 -0
- package/dist/scaffold/transform-integration-configs.d.ts.map +1 -0
- package/dist/scaffold/transform-integration-configs.js +110 -0
- package/dist/scaffold/transform-package-json.d.ts +2 -0
- package/dist/scaffold/transform-package-json.d.ts.map +1 -0
- package/dist/scaffold/transform-package-json.js +61 -0
- package/dist/scaffold/transform-page-model.d.ts +2 -0
- package/dist/scaffold/transform-page-model.d.ts.map +1 -0
- package/dist/scaffold/transform-page-model.js +78 -0
- package/dist/scaffold/transform-render-blocks.d.ts +2 -0
- package/dist/scaffold/transform-render-blocks.d.ts.map +1 -0
- package/dist/scaffold/transform-render-blocks.js +102 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/utils/block-discovery.d.ts +3 -0
- package/dist/utils/block-discovery.d.ts.map +1 -0
- package/dist/utils/block-discovery.js +79 -0
- package/dist/utils/integration-discovery.d.ts +3 -0
- package/dist/utils/integration-discovery.d.ts.map +1 -0
- package/dist/utils/integration-discovery.js +79 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +62 -0
- package/dist/wizard/env-prompts.d.ts +10 -0
- package/dist/wizard/env-prompts.d.ts.map +1 -0
- package/dist/wizard/env-prompts.js +66 -0
- package/dist/wizard/index.d.ts +3 -0
- package/dist/wizard/index.d.ts.map +1 -0
- package/dist/wizard/index.js +38 -0
- package/dist/wizard/prompts.d.ts +7 -0
- package/dist/wizard/prompts.d.ts.map +1 -0
- package/dist/wizard/prompts.js +106 -0
- package/dist/wizard/templates.d.ts +11 -0
- package/dist/wizard/templates.d.ts.map +1 -0
- package/dist/wizard/templates.js +47 -0
- package/package.json +25 -4
- package/src/constants.ts +78 -0
- package/src/index.ts +72 -106
- package/src/scaffold/cleanup.ts +21 -0
- package/src/scaffold/clone.ts +47 -0
- package/src/scaffold/generate-env.ts +44 -0
- package/src/scaffold/index.ts +69 -0
- package/src/scaffold/install.ts +47 -0
- package/src/scaffold/transform-app-config.ts +24 -0
- package/src/scaffold/transform-app-module.ts +50 -0
- package/src/scaffold/transform-apps-package-json.ts +59 -0
- package/src/scaffold/transform-integration-configs.ts +101 -0
- package/src/scaffold/transform-package-json.ts +29 -0
- package/src/scaffold/transform-page-model.ts +50 -0
- package/src/scaffold/transform-render-blocks.ts +79 -0
- package/src/types.ts +37 -0
- package/src/utils/block-discovery.ts +54 -0
- package/src/utils/integration-discovery.ts +58 -0
- package/src/utils/logger.ts +68 -0
- package/src/wizard/env-prompts.ts +83 -0
- package/src/wizard/index.ts +49 -0
- package/src/wizard/prompts.ts +119 -0
- package/src/wizard/templates.ts +61 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type TemplateType = 'o2s' | 'dxp' | 'custom';
|
|
2
|
+
export interface BlockInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
packageName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
category: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface IntegrationInfo {
|
|
9
|
+
name: string;
|
|
10
|
+
packageName: string;
|
|
11
|
+
description: string;
|
|
12
|
+
category: string[];
|
|
13
|
+
modules: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface EnvVar {
|
|
16
|
+
key: string;
|
|
17
|
+
description: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface ConflictResolution {
|
|
21
|
+
module: string;
|
|
22
|
+
winner: string;
|
|
23
|
+
}
|
|
24
|
+
export interface WizardAnswers {
|
|
25
|
+
projectName: string;
|
|
26
|
+
template: TemplateType;
|
|
27
|
+
selectedBlocks: string[];
|
|
28
|
+
selectedIntegrations: string[];
|
|
29
|
+
integrationModules: Record<string, string[]>;
|
|
30
|
+
conflictResolutions: ConflictResolution[];
|
|
31
|
+
envVars: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEpD,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,MAAM;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-discovery.d.ts","sourceRoot":"","sources":["../../src/utils/block-discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAUrC,eAAO,MAAM,cAAc,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,SAAS,EAAE,CA2BzE,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.discoverBlocks = void 0;
|
|
37
|
+
const constants_1 = require("../constants");
|
|
38
|
+
const templates_1 = require("../wizard/templates");
|
|
39
|
+
const fs = __importStar(require("fs-extra"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const discoverBlocks = async (repoDir) => {
|
|
42
|
+
try {
|
|
43
|
+
const blocksDir = path.join(repoDir, constants_1.BLOCKS_PATH);
|
|
44
|
+
const entries = await fs.readdir(blocksDir, { withFileTypes: true });
|
|
45
|
+
const blocks = [];
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
if (!entry.isDirectory())
|
|
48
|
+
continue;
|
|
49
|
+
const blockName = entry.name;
|
|
50
|
+
const packageJson = await readBlockPackageJson(repoDir, blockName);
|
|
51
|
+
blocks.push({
|
|
52
|
+
name: blockName,
|
|
53
|
+
packageName: `@o2s/blocks.${blockName}`,
|
|
54
|
+
description: packageJson.description || `Block: ${blockName}`,
|
|
55
|
+
// Fallback to all templates when o2sTemplate is not declared
|
|
56
|
+
category: packageJson.o2sTemplate ?? (0, templates_1.getAllTemplateCategories)(),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return blocks.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Error fetching the block list:', error);
|
|
63
|
+
throw new Error('Failed to fetch the block list.');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.discoverBlocks = discoverBlocks;
|
|
67
|
+
const readBlockPackageJson = async (repoDir, blockName) => {
|
|
68
|
+
try {
|
|
69
|
+
const packageJsonPath = path.join(repoDir, constants_1.BLOCKS_PATH, blockName, 'package.json');
|
|
70
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
71
|
+
return await fs.readJson(packageJsonPath);
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.warn(`Warning: Could not read package.json for block "${blockName}":`, error);
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-discovery.d.ts","sourceRoot":"","sources":["../../src/utils/integration-discovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAU3C,eAAO,MAAM,oBAAoB,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,eAAe,EAAE,CA4BrF,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.discoverIntegrations = void 0;
|
|
37
|
+
const constants_1 = require("../constants");
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const discoverIntegrations = async (repoDir) => {
|
|
41
|
+
try {
|
|
42
|
+
const integrationsDir = path.join(repoDir, constants_1.INTEGRATIONS_PATH);
|
|
43
|
+
const entries = await fs.readdir(integrationsDir, { withFileTypes: true });
|
|
44
|
+
const integrations = [];
|
|
45
|
+
for (const entry of entries) {
|
|
46
|
+
if (!entry.isDirectory())
|
|
47
|
+
continue;
|
|
48
|
+
const integrationName = entry.name;
|
|
49
|
+
const packageJson = await readIntegrationPackageJson(repoDir, integrationName);
|
|
50
|
+
integrations.push({
|
|
51
|
+
name: integrationName,
|
|
52
|
+
packageName: `@o2s/integrations.${integrationName}`,
|
|
53
|
+
description: packageJson.description || `Integration: ${integrationName}`,
|
|
54
|
+
// No o2sTemplate = integration only available in Custom template
|
|
55
|
+
category: packageJson.o2sTemplate ?? [],
|
|
56
|
+
modules: packageJson.o2sModules ?? [],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return integrations.sort((a, b) => a.name.localeCompare(b.name));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Error fetching the integration list:', error);
|
|
63
|
+
throw new Error('Failed to fetch the integration list.');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.discoverIntegrations = discoverIntegrations;
|
|
67
|
+
const readIntegrationPackageJson = async (repoDir, integrationName) => {
|
|
68
|
+
try {
|
|
69
|
+
const packageJsonPath = path.join(repoDir, constants_1.INTEGRATIONS_PATH, integrationName, 'package.json');
|
|
70
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
71
|
+
return await fs.readJson(packageJsonPath);
|
|
72
|
+
}
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.warn(`Warning: Could not read package.json for integration "${integrationName}":`, error);
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TemplateType } from '../types';
|
|
2
|
+
export declare const printSummary: (targetDir: string, template: TemplateType, blockCount: number, integrationCount: number, uncoveredModules?: string[], skipInstall?: boolean) => void;
|
|
3
|
+
export declare const printError: (message: string, error?: unknown) => void;
|
|
4
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAIxC,eAAO,MAAM,YAAY,GACrB,WAAW,MAAM,EACjB,UAAU,YAAY,EACtB,YAAY,MAAM,EAClB,kBAAkB,MAAM,EACxB,mBAAkB,MAAM,EAAO,EAC/B,qBAAmB,KACpB,IA4CF,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,QAAQ,OAAO,KAAG,IAS7D,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
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.printError = exports.printSummary = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const templates_1 = require("../wizard/templates");
|
|
9
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
10
|
+
const printSummary = (targetDir, template, blockCount, integrationCount, uncoveredModules = [], skipInstall = false) => {
|
|
11
|
+
const templateName = templates_1.TEMPLATES[template].name;
|
|
12
|
+
console.log();
|
|
13
|
+
console.log(kleur_1.default.green().bold('Project created successfully!'));
|
|
14
|
+
console.log();
|
|
15
|
+
console.log(` Location: ${kleur_1.default.cyan(targetDir)}`);
|
|
16
|
+
console.log(` Template: ${templateName}`);
|
|
17
|
+
console.log(` Blocks: ${blockCount} blocks`);
|
|
18
|
+
console.log(` Integrations: ${integrationCount} integrations`);
|
|
19
|
+
console.log();
|
|
20
|
+
if (uncoveredModules.length > 0) {
|
|
21
|
+
console.log(kleur_1.default.yellow().bold('⚠ Warning: the following modules have no integration assigned:'));
|
|
22
|
+
console.log();
|
|
23
|
+
for (const mod of uncoveredModules) {
|
|
24
|
+
console.log(kleur_1.default.yellow(` - ${mod}`));
|
|
25
|
+
}
|
|
26
|
+
console.log();
|
|
27
|
+
console.log(kleur_1.default.red(' The project will NOT start until these modules are configured.'));
|
|
28
|
+
console.log(' To fix this, edit packages/configs/integrations/src/models/<module>.ts');
|
|
29
|
+
console.log(' and replace the @o2s/integrations.mocked import with a real integration.');
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(kleur_1.default.bold('Next steps:'));
|
|
32
|
+
console.log();
|
|
33
|
+
console.log(` cd ${targetDir}`);
|
|
34
|
+
console.log(kleur_1.default.dim(' # 1. Configure the modules listed above'));
|
|
35
|
+
console.log(kleur_1.default.dim(' # 2. Add the required env vars to apps/api-harmonization/.env.local'));
|
|
36
|
+
console.log(kleur_1.default.dim(' # 3. npm run dev'));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log(kleur_1.default.bold('Next steps:'));
|
|
40
|
+
console.log();
|
|
41
|
+
console.log(` cd ${targetDir}`);
|
|
42
|
+
if (skipInstall) {
|
|
43
|
+
console.log(kleur_1.default.dim(' # Install dependencies (npm install was skipped)'));
|
|
44
|
+
console.log(' npm install');
|
|
45
|
+
}
|
|
46
|
+
console.log(' npm run dev');
|
|
47
|
+
}
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(kleur_1.default.bold('Documentation:'));
|
|
50
|
+
console.log(kleur_1.default.cyan(` ${constants_1.DOCS_URL}`));
|
|
51
|
+
console.log();
|
|
52
|
+
};
|
|
53
|
+
exports.printSummary = printSummary;
|
|
54
|
+
const printError = (message, error) => {
|
|
55
|
+
console.error();
|
|
56
|
+
console.error(kleur_1.default.red().bold(`Error: ${message}`));
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
console.error(kleur_1.default.red(`Details: ${error.message}`));
|
|
59
|
+
}
|
|
60
|
+
console.error();
|
|
61
|
+
};
|
|
62
|
+
exports.printError = printError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConflictResolution } from '../types';
|
|
2
|
+
interface ModuleConflict {
|
|
3
|
+
module: string;
|
|
4
|
+
integrations: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare const detectConflicts: (selectedIntegrations: string[], integrationModules: Record<string, string[]>) => ModuleConflict[];
|
|
7
|
+
export declare const promptConflictResolutions: (conflicts: ModuleConflict[]) => Promise<ConflictResolution[]>;
|
|
8
|
+
export declare const promptEnvVars: (selectedIntegrations: string[]) => Promise<Record<string, string>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=env-prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-prompts.d.ts","sourceRoot":"","sources":["../../src/wizard/env-prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI9C,UAAU,cAAc;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,eAAe,GACxB,sBAAsB,MAAM,EAAE,EAC9B,oBAAoB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,KAC7C,cAAc,EAahB,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,WAAW,cAAc,EAAE,KAAG,OAAO,CAAC,kBAAkB,EAAE,CAsBzG,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,sBAAsB,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BlG,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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.promptEnvVars = exports.promptConflictResolutions = exports.detectConflicts = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
9
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
10
|
+
const detectConflicts = (selectedIntegrations, integrationModules) => {
|
|
11
|
+
const moduleToIntegrations = {};
|
|
12
|
+
for (const integration of selectedIntegrations) {
|
|
13
|
+
const modules = integrationModules[integration] ?? [];
|
|
14
|
+
for (const module of modules) {
|
|
15
|
+
moduleToIntegrations[module] = [...(moduleToIntegrations[module] ?? []), integration];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return Object.entries(moduleToIntegrations)
|
|
19
|
+
.filter(([, integrations]) => integrations.length > 1)
|
|
20
|
+
.map(([module, integrations]) => ({ module, integrations }));
|
|
21
|
+
};
|
|
22
|
+
exports.detectConflicts = detectConflicts;
|
|
23
|
+
const promptConflictResolutions = async (conflicts) => {
|
|
24
|
+
const resolutions = [];
|
|
25
|
+
for (const conflict of conflicts) {
|
|
26
|
+
const { winner } = await (0, prompts_1.default)({
|
|
27
|
+
type: 'select',
|
|
28
|
+
name: 'winner',
|
|
29
|
+
message: `Which integration should handle the "${conflict.module}" module?`,
|
|
30
|
+
choices: conflict.integrations.map((integration) => ({
|
|
31
|
+
title: integration,
|
|
32
|
+
value: integration,
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
if (!winner) {
|
|
36
|
+
throw new Error(`Conflict resolution for module "${conflict.module}" is required`);
|
|
37
|
+
}
|
|
38
|
+
resolutions.push({ module: conflict.module, winner });
|
|
39
|
+
}
|
|
40
|
+
return resolutions;
|
|
41
|
+
};
|
|
42
|
+
exports.promptConflictResolutions = promptConflictResolutions;
|
|
43
|
+
const promptEnvVars = async (selectedIntegrations) => {
|
|
44
|
+
const envVars = {};
|
|
45
|
+
// Only integrations with defined env vars need configuration
|
|
46
|
+
const realIntegrations = selectedIntegrations.filter((integration) => !!constants_1.INTEGRATION_ENV_VARS[integration]);
|
|
47
|
+
if (realIntegrations.length === 0) {
|
|
48
|
+
return envVars;
|
|
49
|
+
}
|
|
50
|
+
for (const integration of realIntegrations) {
|
|
51
|
+
const vars = constants_1.INTEGRATION_ENV_VARS[integration] ?? [];
|
|
52
|
+
console.log(`\n${kleur_1.default.cyan().bold(`Configuring ${integration}`)} environment variables ${kleur_1.default.dim('(press Enter to skip)')}:`);
|
|
53
|
+
for (const envVar of vars) {
|
|
54
|
+
const requiredLabel = envVar.required ? ' [required]' : ' [optional]';
|
|
55
|
+
const { value } = await (0, prompts_1.default)({
|
|
56
|
+
type: 'text',
|
|
57
|
+
name: 'value',
|
|
58
|
+
message: `${envVar.key}${requiredLabel}`,
|
|
59
|
+
hint: envVar.description,
|
|
60
|
+
});
|
|
61
|
+
envVars[envVar.key] = value ?? '';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return envVars;
|
|
65
|
+
};
|
|
66
|
+
exports.promptEnvVars = promptEnvVars;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wizard/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAMvD,eAAO,MAAM,SAAS,GAClB,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,cAAc,YAAY,EAC1B,YAAY,MAAM,EAAE,EACpB,kBAAkB,MAAM,EAAE,KAC3B,OAAO,CAAC,aAAa,CAoCvB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runWizard = void 0;
|
|
4
|
+
const block_discovery_1 = require("../utils/block-discovery");
|
|
5
|
+
const integration_discovery_1 = require("../utils/integration-discovery");
|
|
6
|
+
const env_prompts_1 = require("./env-prompts");
|
|
7
|
+
const prompts_1 = require("./prompts");
|
|
8
|
+
const runWizard = async (repoDir, cliName, cliTemplate, cliBlocks, cliIntegrations) => {
|
|
9
|
+
const [allBlocks, allIntegrations] = await Promise.all([(0, block_discovery_1.discoverBlocks)(repoDir), (0, integration_discovery_1.discoverIntegrations)(repoDir)]);
|
|
10
|
+
console.log(`Found ${allBlocks.length} blocks and ${allIntegrations.length} integrations.`);
|
|
11
|
+
console.log();
|
|
12
|
+
const integrationModules = Object.fromEntries(allIntegrations.map((i) => [i.name, i.modules]));
|
|
13
|
+
if (cliName && cliTemplate && cliBlocks && cliIntegrations) {
|
|
14
|
+
return {
|
|
15
|
+
projectName: cliName,
|
|
16
|
+
template: cliTemplate,
|
|
17
|
+
selectedBlocks: cliBlocks,
|
|
18
|
+
selectedIntegrations: cliIntegrations,
|
|
19
|
+
integrationModules,
|
|
20
|
+
conflictResolutions: [],
|
|
21
|
+
envVars: {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const partialAnswers = await (0, prompts_1.runWizardPrompts)(allBlocks, allIntegrations, cliName, cliTemplate);
|
|
25
|
+
if (partialAnswers.template !== 'custom') {
|
|
26
|
+
return { ...partialAnswers, integrationModules };
|
|
27
|
+
}
|
|
28
|
+
const conflicts = (0, env_prompts_1.detectConflicts)(partialAnswers.selectedIntegrations, integrationModules);
|
|
29
|
+
const conflictResolutions = await (0, env_prompts_1.promptConflictResolutions)(conflicts);
|
|
30
|
+
const envVars = await (0, env_prompts_1.promptEnvVars)(partialAnswers.selectedIntegrations);
|
|
31
|
+
return {
|
|
32
|
+
...partialAnswers,
|
|
33
|
+
integrationModules,
|
|
34
|
+
conflictResolutions,
|
|
35
|
+
envVars,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
exports.runWizard = runWizard;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BlockInfo, IntegrationInfo, TemplateType, WizardAnswers } from '../types';
|
|
2
|
+
export declare const promptProjectName: (defaultName: string) => Promise<string>;
|
|
3
|
+
export declare const promptTemplate: () => Promise<TemplateType>;
|
|
4
|
+
export declare const promptBlockSelection: (availableBlocks: BlockInfo[], preselected: string[]) => Promise<string[]>;
|
|
5
|
+
export declare const promptIntegrationSelection: (availableIntegrations: IntegrationInfo[], preselected: string[]) => Promise<string[]>;
|
|
6
|
+
export declare const runWizardPrompts: (availableBlocks: BlockInfo[], availableIntegrations: IntegrationInfo[], cliName?: string, cliTemplate?: TemplateType) => Promise<Omit<WizardAnswers, "integrationModules">>;
|
|
7
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/wizard/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAKnF,eAAO,MAAM,iBAAiB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,MAAM,CAa3E,CAAC;AAEF,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,YAAY,CAiB3D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAU,iBAAiB,SAAS,EAAE,EAAE,aAAa,MAAM,EAAE,KAAG,OAAO,CAAC,MAAM,EAAE,CAqBhH,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACnC,uBAAuB,eAAe,EAAE,EACxC,aAAa,MAAM,EAAE,KACtB,OAAO,CAAC,MAAM,EAAE,CAgBlB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GACzB,iBAAiB,SAAS,EAAE,EAC5B,uBAAuB,eAAe,EAAE,EACxC,UAAU,MAAM,EAChB,cAAc,YAAY,KAC3B,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,CAAC,CA6BnD,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
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.runWizardPrompts = exports.promptIntegrationSelection = exports.promptBlockSelection = exports.promptTemplate = exports.promptProjectName = void 0;
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const templates_1 = require("./templates");
|
|
9
|
+
const kleur_1 = __importDefault(require("kleur"));
|
|
10
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
11
|
+
const promptProjectName = async (defaultName) => {
|
|
12
|
+
const { name } = await (0, prompts_1.default)({
|
|
13
|
+
type: 'text',
|
|
14
|
+
name: 'name',
|
|
15
|
+
message: 'What is your project named?',
|
|
16
|
+
initial: defaultName,
|
|
17
|
+
});
|
|
18
|
+
if (!name) {
|
|
19
|
+
throw new Error('Project name is required');
|
|
20
|
+
}
|
|
21
|
+
return name;
|
|
22
|
+
};
|
|
23
|
+
exports.promptProjectName = promptProjectName;
|
|
24
|
+
const promptTemplate = async () => {
|
|
25
|
+
const { template } = await (0, prompts_1.default)({
|
|
26
|
+
type: 'select',
|
|
27
|
+
name: 'template',
|
|
28
|
+
message: 'What template do you want to start with?',
|
|
29
|
+
choices: Object.entries(templates_1.TEMPLATES).map(([key, template]) => ({
|
|
30
|
+
title: template.name,
|
|
31
|
+
description: template.description,
|
|
32
|
+
value: key,
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
if (!template) {
|
|
36
|
+
throw new Error('Template selection is required');
|
|
37
|
+
}
|
|
38
|
+
return template;
|
|
39
|
+
};
|
|
40
|
+
exports.promptTemplate = promptTemplate;
|
|
41
|
+
const promptBlockSelection = async (availableBlocks, preselected) => {
|
|
42
|
+
const { selectedBlocks } = await (0, prompts_1.default)({
|
|
43
|
+
type: 'multiselect',
|
|
44
|
+
name: 'selectedBlocks',
|
|
45
|
+
message: 'Select blocks to include:',
|
|
46
|
+
choices: availableBlocks.map((block) => ({
|
|
47
|
+
title: block.name,
|
|
48
|
+
description: block.description,
|
|
49
|
+
value: block.name,
|
|
50
|
+
selected: preselected.includes(block.name),
|
|
51
|
+
})),
|
|
52
|
+
min: 1,
|
|
53
|
+
instructions: false,
|
|
54
|
+
hint: '- Space to select. Return to submit',
|
|
55
|
+
});
|
|
56
|
+
if (!selectedBlocks || selectedBlocks.length === 0) {
|
|
57
|
+
throw new Error('At least one block must be selected');
|
|
58
|
+
}
|
|
59
|
+
return selectedBlocks;
|
|
60
|
+
};
|
|
61
|
+
exports.promptBlockSelection = promptBlockSelection;
|
|
62
|
+
const promptIntegrationSelection = async (availableIntegrations, preselected) => {
|
|
63
|
+
const { selectedIntegrations } = await (0, prompts_1.default)({
|
|
64
|
+
type: 'multiselect',
|
|
65
|
+
name: 'selectedIntegrations',
|
|
66
|
+
message: 'Select integrations to include:',
|
|
67
|
+
choices: availableIntegrations.map((integration) => ({
|
|
68
|
+
title: integration.name,
|
|
69
|
+
description: integration.description,
|
|
70
|
+
value: integration.name,
|
|
71
|
+
selected: preselected.includes(integration.name),
|
|
72
|
+
})),
|
|
73
|
+
instructions: false,
|
|
74
|
+
hint: '- Space to select. Return to submit',
|
|
75
|
+
});
|
|
76
|
+
return selectedIntegrations ?? [];
|
|
77
|
+
};
|
|
78
|
+
exports.promptIntegrationSelection = promptIntegrationSelection;
|
|
79
|
+
const runWizardPrompts = async (availableBlocks, availableIntegrations, cliName, cliTemplate) => {
|
|
80
|
+
const projectName = cliName || (await (0, exports.promptProjectName)('my-o2s-project'));
|
|
81
|
+
const template = cliTemplate || (await (0, exports.promptTemplate)());
|
|
82
|
+
let selectedBlocks;
|
|
83
|
+
let selectedIntegrations;
|
|
84
|
+
if (template === 'custom') {
|
|
85
|
+
console.log();
|
|
86
|
+
console.log(kleur_1.default.cyan().bold(' Tip:') + ' Not sure which blocks to pick?');
|
|
87
|
+
console.log(` Browse our Storybook to preview all available components:`);
|
|
88
|
+
console.log(kleur_1.default.cyan(` ${constants_1.STORYBOOK_URL}`));
|
|
89
|
+
console.log();
|
|
90
|
+
selectedBlocks = await (0, exports.promptBlockSelection)(availableBlocks, []);
|
|
91
|
+
selectedIntegrations = await (0, exports.promptIntegrationSelection)(availableIntegrations, []);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
selectedBlocks = (0, templates_1.filterBlocksByTemplate)(template, availableBlocks);
|
|
95
|
+
selectedIntegrations = (0, templates_1.filterIntegrationsByTemplate)(template, availableIntegrations);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
projectName,
|
|
99
|
+
template,
|
|
100
|
+
selectedBlocks,
|
|
101
|
+
selectedIntegrations,
|
|
102
|
+
conflictResolutions: [],
|
|
103
|
+
envVars: {},
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
exports.runWizardPrompts = runWizardPrompts;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BlockInfo, IntegrationInfo, TemplateType } from '../types';
|
|
2
|
+
export interface TemplateDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category: 'o2s' | 'dxp' | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const TEMPLATES: Record<TemplateType, TemplateDefinition>;
|
|
8
|
+
export declare const getAllTemplateCategories: () => string[];
|
|
9
|
+
export declare const filterBlocksByTemplate: (template: TemplateType, allBlocks: BlockInfo[]) => string[];
|
|
10
|
+
export declare const filterIntegrationsByTemplate: (template: TemplateType, allIntegrations: IntegrationInfo[]) => string[];
|
|
11
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/wizard/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAkB9D,CAAC;AAGF,eAAO,MAAM,wBAAwB,QAAO,MAAM,EACoC,CAAC;AAGvF,eAAO,MAAM,sBAAsB,GAAI,UAAU,YAAY,EAAE,WAAW,SAAS,EAAE,KAAG,MAAM,EAW7F,CAAC;AAIF,eAAO,MAAM,4BAA4B,GAAI,UAAU,YAAY,EAAE,iBAAiB,eAAe,EAAE,KAAG,MAAM,EAY/G,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterIntegrationsByTemplate = exports.filterBlocksByTemplate = exports.getAllTemplateCategories = exports.TEMPLATES = void 0;
|
|
4
|
+
exports.TEMPLATES = {
|
|
5
|
+
o2s: {
|
|
6
|
+
name: 'Self Service Portal',
|
|
7
|
+
description: 'Demo — best way to see the full Self Service Portal flow. Customer support: tickets, orders, invoices, notifications',
|
|
8
|
+
category: 'o2s',
|
|
9
|
+
},
|
|
10
|
+
dxp: {
|
|
11
|
+
name: 'Digital Experience Platform (DXP)',
|
|
12
|
+
description: 'Demo — best way to see the full Digital Experience Platform flow. Marketing and content: hero sections, features, pricing',
|
|
13
|
+
category: 'dxp',
|
|
14
|
+
},
|
|
15
|
+
custom: {
|
|
16
|
+
name: 'Custom',
|
|
17
|
+
description: 'Select individual blocks and integrations',
|
|
18
|
+
category: null,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
// Returns all known template category identifiers (excludes null for custom)
|
|
22
|
+
const getAllTemplateCategories = () => Object.values(exports.TEMPLATES).flatMap((t) => (t.category !== null ? [t.category] : []));
|
|
23
|
+
exports.getAllTemplateCategories = getAllTemplateCategories;
|
|
24
|
+
// Filter discovered blocks by template category
|
|
25
|
+
const filterBlocksByTemplate = (template, allBlocks) => {
|
|
26
|
+
const templateDef = exports.TEMPLATES[template];
|
|
27
|
+
const { category } = templateDef;
|
|
28
|
+
if (!category) {
|
|
29
|
+
return []; // Custom template - user selects manually
|
|
30
|
+
}
|
|
31
|
+
// Include blocks that declare support for this template category
|
|
32
|
+
return allBlocks.filter((block) => block.category.includes(category)).map((block) => block.name);
|
|
33
|
+
};
|
|
34
|
+
exports.filterBlocksByTemplate = filterBlocksByTemplate;
|
|
35
|
+
// Filter discovered integrations by template category
|
|
36
|
+
// For O2S/DXP demo templates, only mocked integrations are pre-selected.
|
|
37
|
+
const filterIntegrationsByTemplate = (template, allIntegrations) => {
|
|
38
|
+
const templateDef = exports.TEMPLATES[template];
|
|
39
|
+
const { category } = templateDef;
|
|
40
|
+
if (!category) {
|
|
41
|
+
return []; // Custom template - user selects manually
|
|
42
|
+
}
|
|
43
|
+
return allIntegrations
|
|
44
|
+
.filter((integration) => integration.category.includes(category))
|
|
45
|
+
.map((integration) => integration.name);
|
|
46
|
+
};
|
|
47
|
+
exports.filterIntegrationsByTemplate = filterIntegrationsByTemplate;
|