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.
- package/CHANGELOG.md +21 -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 +73 -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 +86 -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 +64 -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 +116 -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 +76 -0
- package/src/index.ts +72 -106
- package/src/scaffold/cleanup.ts +63 -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 +39 -0
- package/src/scaffold/transform-integration-configs.ts +112 -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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# create-o2s-app
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 600d5ac: feat: add interactive CLI wizard with template selection, block/integration picker, and environment variable configuration
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a288b11: chore(deps): update dependencies
|
|
12
|
+
- 3b8ab83: chore(deps): update dependencies
|
|
13
|
+
- 8c01be4: added README
|
|
14
|
+
- b234a1f: chore(deps): update dependencies
|
|
15
|
+
- fefc45d: chore(deps): update dependencies
|
|
16
|
+
- ea200fc: chore(deps): update dependencies
|
|
17
|
+
- ed74c8f: chore(deps): update dependencies
|
|
18
|
+
- Updated dependencies [a288b11]
|
|
19
|
+
- Updated dependencies [3b8ab83]
|
|
20
|
+
- Updated dependencies [8c01be4]
|
|
21
|
+
- Updated dependencies [ea200fc]
|
|
22
|
+
- @o2s/telemetry@1.2.1
|
|
23
|
+
|
|
3
24
|
## 1.2.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# create-o2s-app
|
|
2
|
+
|
|
3
|
+
CLI tool to scaffold new O2S applications with an interactive setup wizard.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-o2s-app my-app
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Interactive Wizard
|
|
12
|
+
|
|
13
|
+
When you run `create-o2s-app`, it launches an interactive wizard that guides you through the setup:
|
|
14
|
+
|
|
15
|
+
1. **Project name** — Name of the directory to create (can also be passed as a CLI argument)
|
|
16
|
+
2. **Template** — Choose between `o2s`, `dxp`, or `custom`
|
|
17
|
+
3. **Blocks** — Select which UI blocks to include in your project
|
|
18
|
+
4. **Integrations** — Select backend integrations (e.g. Strapi, Zendesk, Medusa)
|
|
19
|
+
5. **Environment variables** — Configure required env vars for selected integrations
|
|
20
|
+
|
|
21
|
+
At the end, the wizard scaffolds your project and installs dependencies.
|
|
22
|
+
|
|
23
|
+
## Templates
|
|
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 |
|
|
30
|
+
|
|
31
|
+
## Options
|
|
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) |
|
|
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) |
|
|
40
|
+
|
|
41
|
+
## Non-Interactive Mode
|
|
42
|
+
|
|
43
|
+
Pass all required options as CLI flags to skip the interactive prompts:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Create an O2S portal with specific blocks and integrations
|
|
47
|
+
npx create-o2s-app@latest my-portal \
|
|
48
|
+
--template o2s \
|
|
49
|
+
--blocks ticket-list,invoice-list \
|
|
50
|
+
--integrations zendesk,strapi-cms
|
|
51
|
+
|
|
52
|
+
# Create a DXP starter, skip install
|
|
53
|
+
npx create-o2s-app@latest my-dxp \
|
|
54
|
+
--template dxp \
|
|
55
|
+
--skip-install
|
|
56
|
+
|
|
57
|
+
# Custom setup with only selected blocks
|
|
58
|
+
npx create-o2s-app@latest my-custom \
|
|
59
|
+
--template custom \
|
|
60
|
+
--blocks article-list,article-details \
|
|
61
|
+
--integrations strapi-cms
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## What It Creates
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
my-app/
|
|
68
|
+
├── apps/
|
|
69
|
+
│ ├── frontend/ # Next.js application
|
|
70
|
+
│ └── api-harmonization/ # NestJS API harmonization server
|
|
71
|
+
├── packages/
|
|
72
|
+
│ ├── blocks/ # Selected UI blocks
|
|
73
|
+
│ └── integrations/ # Selected backend integrations
|
|
74
|
+
├── package.json # Workspace root with Turborepo
|
|
75
|
+
├── turbo.json
|
|
76
|
+
├── tsconfig.json # TypeScript configuration
|
|
77
|
+
├── .eslintrc.js # ESLint configuration
|
|
78
|
+
├── .prettierrc # Prettier configuration
|
|
79
|
+
├── .env.local # Pre-configured env vars for selected integrations
|
|
80
|
+
└── README.md
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The `.env.local` file is generated automatically with all required environment variables for your selected integrations. Fill in the values before starting development.
|
|
84
|
+
|
|
85
|
+
> **Note:** The scaffolded project does not have a git repository initialized. Run `git init` in the project directory to start tracking changes.
|
|
86
|
+
|
|
87
|
+
## Related
|
|
88
|
+
|
|
89
|
+
- [O2S Documentation](https://openselfservice.com/docs)
|
|
90
|
+
- `@o2s/framework` — Core framework types and services
|
|
91
|
+
- `@o2s/telemetry` — Anonymous usage telemetry
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EnvVar } from './types';
|
|
2
|
+
export declare const GITHUB_REPO_URL = "https://github.com/o2sdev/openselfservice";
|
|
3
|
+
export declare const GITHUB_BRANCH = "create-o2s-app/base";
|
|
4
|
+
export declare const PROJECT_PREFIX = "o2s";
|
|
5
|
+
export declare const STORYBOOK_URL = "https://storybook-o2s.openselfservice.com/";
|
|
6
|
+
export declare const DOCS_URL = "https://docs.openselfservice.com/getting-started";
|
|
7
|
+
export declare const BLOCKS_PATH = "packages/blocks";
|
|
8
|
+
export declare const INTEGRATIONS_PATH = "packages/integrations";
|
|
9
|
+
export declare const ALWAYS_REMOVE_DIRS: string[];
|
|
10
|
+
export declare const ALWAYS_REMOVE_FILES: string[];
|
|
11
|
+
export declare const INTEGRATION_ENV_VARS: Record<string, EnvVar[]>;
|
|
12
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.INTEGRATION_ENV_VARS = exports.ALWAYS_REMOVE_FILES = exports.ALWAYS_REMOVE_DIRS = exports.INTEGRATIONS_PATH = exports.BLOCKS_PATH = exports.DOCS_URL = exports.STORYBOOK_URL = exports.PROJECT_PREFIX = exports.GITHUB_BRANCH = exports.GITHUB_REPO_URL = void 0;
|
|
4
|
+
exports.GITHUB_REPO_URL = 'https://github.com/o2sdev/openselfservice';
|
|
5
|
+
exports.GITHUB_BRANCH = 'create-o2s-app/base';
|
|
6
|
+
exports.PROJECT_PREFIX = 'o2s';
|
|
7
|
+
exports.STORYBOOK_URL = 'https://storybook-o2s.openselfservice.com/';
|
|
8
|
+
exports.DOCS_URL = 'https://docs.openselfservice.com/getting-started';
|
|
9
|
+
exports.BLOCKS_PATH = 'packages/blocks';
|
|
10
|
+
exports.INTEGRATIONS_PATH = 'packages/integrations';
|
|
11
|
+
// Directories always removed during scaffolding
|
|
12
|
+
exports.ALWAYS_REMOVE_DIRS = [
|
|
13
|
+
'.git',
|
|
14
|
+
'.github',
|
|
15
|
+
'.changeset',
|
|
16
|
+
'apps/docs',
|
|
17
|
+
'packages/framework',
|
|
18
|
+
'packages/modules',
|
|
19
|
+
'packages/utils',
|
|
20
|
+
'packages/cli',
|
|
21
|
+
'packages/telemetry',
|
|
22
|
+
];
|
|
23
|
+
exports.ALWAYS_REMOVE_FILES = ['vercel.json'];
|
|
24
|
+
exports.INTEGRATION_ENV_VARS = {
|
|
25
|
+
zendesk: [
|
|
26
|
+
{
|
|
27
|
+
key: 'ZENDESK_API_URL',
|
|
28
|
+
description: 'Zendesk API URL (e.g., https://your-domain.zendesk.com)',
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
{ key: 'ZENDESK_API_TOKEN', description: 'Zendesk API token for authentication', required: true },
|
|
32
|
+
{ key: 'ZENDESK_TOPIC_FIELD_ID', description: 'Zendesk custom field ID for ticket topic', required: false },
|
|
33
|
+
],
|
|
34
|
+
'strapi-cms': [
|
|
35
|
+
{
|
|
36
|
+
key: 'CMS_STRAPI_BASE_URL',
|
|
37
|
+
description: 'Strapi server URL (e.g., https://your-strapi.com)',
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
{ key: 'CMS_STRAPI_API_KEY', description: 'Strapi API key', required: false },
|
|
41
|
+
],
|
|
42
|
+
'contentful-cms': [
|
|
43
|
+
{ key: 'CF_SPACE_ID', description: 'Contentful space identifier', required: true },
|
|
44
|
+
{ key: 'CF_ENV', description: 'Contentful environment (e.g., master)', required: true },
|
|
45
|
+
{ key: 'CF_TOKEN', description: 'Contentful Content Delivery API token', required: true },
|
|
46
|
+
{ key: 'CF_PREVIEW_TOKEN', description: 'Contentful Content Preview API token', required: false },
|
|
47
|
+
],
|
|
48
|
+
medusajs: [
|
|
49
|
+
{
|
|
50
|
+
key: 'MEDUSAJS_BASE_URL',
|
|
51
|
+
description: 'Medusa server URL (e.g., https://api.your-medusa.com)',
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
key: 'MEDUSAJS_PUBLISHABLE_API_KEY',
|
|
56
|
+
description: 'Medusa publishable API key for Store API',
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
{ key: 'MEDUSAJS_ADMIN_API_KEY', description: 'Medusa admin API key for Admin API', required: true },
|
|
60
|
+
],
|
|
61
|
+
algolia: [
|
|
62
|
+
{ key: 'ALGOLIA_APP_ID', description: 'Algolia application ID', required: true },
|
|
63
|
+
{ key: 'ALGOLIA_API_KEY', description: 'Algolia API key', required: true },
|
|
64
|
+
{ key: 'ALGOLIA_INDEX_NAME', description: 'Default Algolia index name', required: false },
|
|
65
|
+
],
|
|
66
|
+
redis: [
|
|
67
|
+
{ key: 'CACHE_ENABLED', description: 'Enable Redis cache (true/false)', required: false },
|
|
68
|
+
{ key: 'CACHE_REDIS_HOST', description: 'Redis host (e.g., localhost)', required: false },
|
|
69
|
+
{ key: 'CACHE_REDIS_PORT', description: 'Redis port (e.g., 6379)', required: false },
|
|
70
|
+
{ key: 'CACHE_REDIS_PASS', description: 'Redis password (if required)', required: false },
|
|
71
|
+
{ key: 'CACHE_TTL', description: 'Cache TTL in seconds (default: 300)', required: false },
|
|
72
|
+
],
|
|
73
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -33,112 +33,80 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const clone_1 = require("./scaffold/clone");
|
|
38
|
+
const index_1 = require("./scaffold/index");
|
|
39
|
+
const logger_1 = require("./utils/logger");
|
|
40
|
+
const index_2 = require("./wizard/index");
|
|
40
41
|
const telemetry = __importStar(require("@o2s/telemetry"));
|
|
41
|
-
const child_process_1 = require("child_process");
|
|
42
|
-
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
43
42
|
const commander_1 = require("commander");
|
|
44
|
-
const fs_1 = require("fs");
|
|
45
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
46
|
-
const simple_git_1 = __importDefault(require("simple-git"));
|
|
47
43
|
const program = new commander_1.Command();
|
|
48
44
|
program
|
|
49
|
-
.name('create-
|
|
50
|
-
.description('Create a new O2S project')
|
|
45
|
+
.name('create-o2s-app')
|
|
46
|
+
.description('Create a new O2S project with interactive setup wizard')
|
|
51
47
|
.argument('[name]', 'Name of the new project')
|
|
52
|
-
.option('--directory [directory]', 'Specify the destination directory'
|
|
48
|
+
.option('--directory [directory]', 'Specify the destination directory')
|
|
49
|
+
.option('--template [template]', 'Template: o2s | dxp | custom')
|
|
50
|
+
.option('--blocks [blocks]', 'Comma-separated list of block names (for non-interactive mode)')
|
|
51
|
+
.option('--integrations [integrations]', 'Comma-separated list of integration names (for non-interactive mode)')
|
|
52
|
+
.option('--skip-install', 'Skip npm install step')
|
|
53
53
|
.action(async (name, options) => {
|
|
54
54
|
telemetry.sendEvent('o2s', 'create-o2s-app', 'create-project');
|
|
55
55
|
await telemetry.flushEvents();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: (await (0, prompts_1.default)({
|
|
59
|
-
type: 'text',
|
|
60
|
-
name: 'name',
|
|
61
|
-
message: 'Enter the name of your project',
|
|
62
|
-
initial: 'my-o2s-project',
|
|
63
|
-
})).name;
|
|
64
|
-
const targetDirectory = projectName || options.directory;
|
|
65
|
-
const githubRepo = 'https://github.com/o2sdev/openselfservice';
|
|
66
|
-
const githubBranch = 'create-o2s-app/base';
|
|
67
|
-
if ((0, fs_1.existsSync)(targetDirectory)) {
|
|
68
|
-
console.error(`Directory ${targetDirectory} already exists. Please choose a different name or remove the existing directory.`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const bar = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
|
|
56
|
+
let tempDir;
|
|
57
|
+
let phase = 'clone';
|
|
72
58
|
try {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.log('Organizing the project structure...');
|
|
88
|
-
(0, fs_1.rmSync)(`${targetDirectory}/.git`, { recursive: true });
|
|
89
|
-
(0, fs_1.rmSync)(`${targetDirectory}/.github`, { recursive: true });
|
|
90
|
-
(0, fs_1.rmSync)(`${targetDirectory}/.changeset`, { recursive: true });
|
|
91
|
-
(0, fs_1.rmSync)(`${targetDirectory}/vercel.json`, { recursive: true });
|
|
92
|
-
(0, fs_1.rmSync)(`${targetDirectory}/apps/docs`, { recursive: true });
|
|
93
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/framework`, { recursive: true });
|
|
94
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/integrations`, { recursive: true });
|
|
95
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/blocks`, { recursive: true });
|
|
96
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/modules`, { recursive: true });
|
|
97
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/utils`, { recursive: true });
|
|
98
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/cli`, { recursive: true });
|
|
99
|
-
(0, fs_1.rmSync)(`${targetDirectory}/packages/telemetry`, { recursive: true });
|
|
100
|
-
let file = (0, fs_1.readFileSync)(targetDirectory + '/package-lock.json', 'utf8');
|
|
101
|
-
file = removeSymLinks(file);
|
|
102
|
-
(0, fs_1.writeFileSync)(targetDirectory + '/package-lock.json', file);
|
|
103
|
-
console.log();
|
|
104
|
-
console.log(`Installing dependencies in "${targetDirectory}"...`);
|
|
105
|
-
try {
|
|
106
|
-
(0, child_process_1.execSync)('npm install', {
|
|
107
|
-
cwd: targetDirectory,
|
|
108
|
-
stdio: 'inherit',
|
|
109
|
-
});
|
|
110
|
-
console.log(`Dependencies installed successfully.`);
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
console.error('Error while installing dependencies:', error);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
console.log();
|
|
117
|
-
console.log('Project successfully created! 🎉');
|
|
118
|
-
console.log(`Location: ${targetDirectory}`);
|
|
59
|
+
const cliTemplate = parseTemplate(options.template);
|
|
60
|
+
const cliBlocks = parseCommaSeparated(options.blocks);
|
|
61
|
+
const cliIntegrations = parseCommaSeparated(options.integrations);
|
|
62
|
+
// Step 1: Clone repository to temp directory
|
|
63
|
+
phase = 'clone';
|
|
64
|
+
tempDir = await (0, clone_1.cloneRepository)();
|
|
65
|
+
// Step 2: Run wizard (interactive or non-interactive)
|
|
66
|
+
phase = 'wizard';
|
|
67
|
+
const answers = await (0, index_2.runWizard)(tempDir, name, cliTemplate, cliBlocks, cliIntegrations);
|
|
68
|
+
// Step 3: Scaffold project
|
|
69
|
+
phase = 'scaffold';
|
|
70
|
+
const { targetDir, uncoveredModules } = await (0, index_1.scaffold)(tempDir, answers, options.skipInstall, options.directory);
|
|
71
|
+
// Step 4: Print summary
|
|
72
|
+
(0, logger_1.printSummary)(targetDir, answers.template, answers.selectedBlocks.length, answers.selectedIntegrations.length, uncoveredModules, options.skipInstall);
|
|
119
73
|
}
|
|
120
74
|
catch (error) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
75
|
+
if (tempDir) {
|
|
76
|
+
await (0, clone_1.cleanupTempDir)(tempDir);
|
|
77
|
+
}
|
|
78
|
+
if (error instanceof Error && error.message.includes('is required')) {
|
|
79
|
+
// User cancelled a prompt
|
|
80
|
+
console.error();
|
|
81
|
+
console.error('Setup cancelled.');
|
|
125
82
|
}
|
|
126
83
|
else {
|
|
127
|
-
|
|
84
|
+
telemetry.sendEvent('o2s', 'create-o2s-app', 'create-project-error', {
|
|
85
|
+
phase,
|
|
86
|
+
errorMessage: error instanceof Error ? error.message : 'unknown error',
|
|
87
|
+
});
|
|
88
|
+
await telemetry.flushEvents();
|
|
89
|
+
(0, logger_1.printError)('Failed to create project', error);
|
|
128
90
|
}
|
|
91
|
+
process.exit(1);
|
|
129
92
|
}
|
|
130
93
|
});
|
|
131
94
|
program.parse(process.argv);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
delete json.packages[key];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
95
|
+
const parseTemplate = (value) => {
|
|
96
|
+
if (!value || typeof value !== 'string')
|
|
97
|
+
return undefined;
|
|
98
|
+
const valid = ['o2s', 'dxp', 'custom'];
|
|
99
|
+
if (valid.includes(value)) {
|
|
100
|
+
return value;
|
|
141
101
|
}
|
|
142
|
-
|
|
143
|
-
return
|
|
102
|
+
console.warn(`Warning: Unknown template "${value}". Valid options: o2s, dxp, custom`);
|
|
103
|
+
return undefined;
|
|
104
|
+
};
|
|
105
|
+
const parseCommaSeparated = (value) => {
|
|
106
|
+
if (!value || typeof value !== 'string')
|
|
107
|
+
return undefined;
|
|
108
|
+
return value
|
|
109
|
+
.split(',')
|
|
110
|
+
.map((s) => s.trim())
|
|
111
|
+
.filter((s) => s.length > 0);
|
|
144
112
|
};
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.cleanupProject = void 0;
|
|
37
|
+
const constants_1 = require("../constants");
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const cleanupProject = async (projectDir, selectedBlockNames, selectedIntegrationNames) => {
|
|
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
|
+
for (const dir of constants_1.ALWAYS_REMOVE_DIRS) {
|
|
49
|
+
const fullPath = path.join(projectDir, dir);
|
|
50
|
+
if (await fs.pathExists(fullPath)) {
|
|
51
|
+
await fs.remove(fullPath);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const file of constants_1.ALWAYS_REMOVE_FILES) {
|
|
55
|
+
const fullPath = path.join(projectDir, file);
|
|
56
|
+
if (await fs.pathExists(fullPath)) {
|
|
57
|
+
await fs.remove(fullPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../src/scaffold/clone.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,QAAa,OAAO,CAAC,MAAM,CA6BtD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,IAAI,CAQlE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.cleanupTempDir = exports.cloneRepository = void 0;
|
|
40
|
+
const constants_1 = require("../constants");
|
|
41
|
+
const cli_progress_1 = __importDefault(require("cli-progress"));
|
|
42
|
+
const fs = __importStar(require("fs-extra"));
|
|
43
|
+
const os = __importStar(require("os"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
46
|
+
const cloneRepository = async () => {
|
|
47
|
+
const tempDir = path.join(os.tmpdir(), `openselfservice-${Date.now()}`);
|
|
48
|
+
await fs.ensureDir(tempDir);
|
|
49
|
+
console.log(`Cloning template from "${constants_1.GITHUB_REPO_URL}" (branch: "${constants_1.GITHUB_BRANCH}")...`);
|
|
50
|
+
console.log();
|
|
51
|
+
const bar = new cli_progress_1.default.SingleBar({}, cli_progress_1.default.Presets.shades_classic);
|
|
52
|
+
bar.start(100, 0);
|
|
53
|
+
try {
|
|
54
|
+
const git = (0, simple_git_1.default)({
|
|
55
|
+
progress({ progress }) {
|
|
56
|
+
bar.update(Math.round(progress));
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
await git.clone(constants_1.GITHUB_REPO_URL, tempDir, ['--branch', constants_1.GITHUB_BRANCH, '--single-branch', '--depth', '1']);
|
|
60
|
+
bar.update(100);
|
|
61
|
+
bar.stop();
|
|
62
|
+
console.log();
|
|
63
|
+
return tempDir;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
bar.stop();
|
|
67
|
+
console.error('Error cloning repository:', error);
|
|
68
|
+
throw new Error('Failed to clone repository.');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.cloneRepository = cloneRepository;
|
|
72
|
+
const cleanupTempDir = async (tempDir) => {
|
|
73
|
+
try {
|
|
74
|
+
if (await fs.pathExists(tempDir)) {
|
|
75
|
+
await fs.remove(tempDir);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (_error) {
|
|
79
|
+
console.error('Error cleaning up temporary directory:', _error);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.cleanupTempDir = cleanupTempDir;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-env.d.ts","sourceRoot":"","sources":["../../src/scaffold/generate-env.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,gBAAgB,GACzB,YAAY,MAAM,EAClB,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,sBAAsB,MAAM,EAAE,KAC/B,OAAO,CAAC,IAAI,CAYd,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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.generateEnvFiles = void 0;
|
|
37
|
+
const constants_1 = require("../constants");
|
|
38
|
+
const fs = __importStar(require("fs-extra"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
// Updates existing .env.local by replacing KEY= placeholders with user-provided values.
|
|
41
|
+
// The base branch already contains .env.local with all required variables and defaults.
|
|
42
|
+
const updateEnvFile = async (filePath, envVars) => {
|
|
43
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
44
|
+
const lines = content.split('\n');
|
|
45
|
+
const updated = lines.map((line) => {
|
|
46
|
+
const match = line.match(/^([A-Z0-9_]+)=(.*)$/);
|
|
47
|
+
if (!match || !match[1])
|
|
48
|
+
return line;
|
|
49
|
+
const key = match[1];
|
|
50
|
+
const value = envVars[key];
|
|
51
|
+
if (value !== undefined && value !== '') {
|
|
52
|
+
return `${key}=${value}`;
|
|
53
|
+
}
|
|
54
|
+
return line;
|
|
55
|
+
});
|
|
56
|
+
await fs.writeFile(filePath, updated.join('\n'), 'utf-8');
|
|
57
|
+
};
|
|
58
|
+
const generateEnvFiles = async (projectDir, envVars, selectedIntegrations) => {
|
|
59
|
+
const realIntegrations = selectedIntegrations.filter((integration) => !!constants_1.INTEGRATION_ENV_VARS[integration]);
|
|
60
|
+
if (realIntegrations.length === 0) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const apiEnvPath = path.join(projectDir, 'apps', 'api-harmonization', '.env.local');
|
|
64
|
+
if (await fs.pathExists(apiEnvPath)) {
|
|
65
|
+
await updateEnvFile(apiEnvPath, envVars);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.generateEnvFiles = generateEnvFiles;
|
|
@@ -0,0 +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"}
|