create-o2s-app 3.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 +11 -0
- package/README.md +14 -14
- package/dist/scaffold/index.d.ts.map +1 -1
- package/dist/scaffold/index.js +26 -8
- package/dist/scaffold/install.d.ts +9 -5
- package/dist/scaffold/install.d.ts.map +1 -1
- package/dist/scaffold/install.js +42 -7
- package/dist/scaffold/transform-integration-configs.d.ts +1 -1
- package/dist/scaffold/transform-integration-configs.d.ts.map +1 -1
- package/dist/scaffold/transform-integration-configs.js +20 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +5 -2
- package/package.json +1 -1
- package/src/scaffold/index.ts +39 -7
- package/src/scaffold/install.ts +45 -7
- package/src/scaffold/transform-integration-configs.ts +27 -9
- package/src/utils/logger.ts +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 3.0.0
|
|
4
15
|
|
|
5
16
|
### 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`
|
|
28
|
-
| `dxp`
|
|
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
|
|
34
|
-
|
|
35
|
-
| `--template <template>`
|
|
36
|
-
| `--blocks <blocks>`
|
|
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`
|
|
39
|
-
| `--directory <dir>`
|
|
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
|
|
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
|
|
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
|
|
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":"index.d.ts","sourceRoot":"","sources":["../../src/scaffold/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/scaffold/index.js
CHANGED
|
@@ -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:
|
|
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)
|
|
60
78
|
await (0, cleanup_1.cleanupProject)(targetDir);
|
|
61
|
-
// Step
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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":"
|
|
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"}
|
package/dist/scaffold/install.js
CHANGED
|
@@ -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
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
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
|
|
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,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;
|
|
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) => {
|
|
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(
|
|
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,17 +73,27 @@ const updateConfigsPackageJson = async (projectDir, selectedIntegrations) => {
|
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
}
|
|
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
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
73
86
|
await fs.writeJson(pkgPath, pkg, { spaces: 4 });
|
|
74
87
|
};
|
|
75
|
-
const transformIntegrationConfigs = async (projectDir, selectedIntegrations, conflictResolutions, integrationModules) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return [];
|
|
79
|
-
}
|
|
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);
|
|
80
91
|
const modelsDir = path.join(projectDir, CONFIGS_MODELS_PATH);
|
|
81
92
|
if (!(await fs.pathExists(modelsDir))) {
|
|
82
93
|
return [];
|
|
83
94
|
}
|
|
95
|
+
// Replace mocked imports with selected integration imports
|
|
96
|
+
const moduleMap = buildModuleIntegrationMap(selectedIntegrations, conflictResolutions, integrationModules);
|
|
84
97
|
for (const [module, integration] of moduleMap.entries()) {
|
|
85
98
|
const filePath = path.join(modelsDir, `${module}.ts`);
|
|
86
99
|
if (!(await fs.pathExists(filePath)))
|
|
@@ -89,7 +102,6 @@ const transformIntegrationConfigs = async (projectDir, selectedIntegrations, con
|
|
|
89
102
|
const updatedContent = content.replaceAll(MOCKED_IMPORT, `@o2s/integrations.${integration}/integration`);
|
|
90
103
|
await fs.writeFile(filePath, updatedContent, 'utf-8');
|
|
91
104
|
}
|
|
92
|
-
await updateConfigsPackageJson(projectDir, selectedIntegrations);
|
|
93
105
|
// Detect model files that still import mocked but mocked is not selected.
|
|
94
106
|
// Skip only when 'mocked' (full) is selected — it covers all modules.
|
|
95
107
|
// 'mocked-dxp' covers only cms/articles/search, so uncovered detection runs normally.
|