create-o2s-app 3.0.0 → 4.1.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.
@@ -1,58 +1,164 @@
1
- import { DOCS_URL } from '../constants';
1
+ import { DOCS_INTEGRATIONS_URL, DOCS_URL, STORYBOOK_URL } from '../constants';
2
2
  import { TemplateType } from '../types';
3
3
  import { TEMPLATES } from '../wizard/templates';
4
4
  import kleur from 'kleur';
5
+ import path from 'path';
6
+
7
+ export const printBanner = (): void => {
8
+ const title = 'Open Self Service CLI';
9
+ const desc = 'Scaffold your custom composable frontend';
10
+ const contentWidth = 46;
11
+
12
+ const topLine = ` ${kleur.blue('╭' + '─'.repeat(contentWidth) + '╮')}`;
13
+ const empty = ` ${kleur.blue('│')}${' '.repeat(contentWidth)}${kleur.blue('│')}`;
14
+ const bottomLine = ` ${kleur.blue('╰' + '─'.repeat(contentWidth) + '╯')}`;
15
+
16
+ const titlePad = Math.floor((contentWidth - title.length) / 2);
17
+ const titleRightPad = contentWidth - title.length - titlePad;
18
+ const titleLine = ` ${kleur.blue('│')}${' '.repeat(titlePad)}${kleur.bold().white(title)}${' '.repeat(titleRightPad)}${kleur.blue('│')}`;
19
+
20
+ const descPad = Math.floor((contentWidth - desc.length) / 2);
21
+ const descRightPad = contentWidth - desc.length - descPad;
22
+ const descLine = ` ${kleur.blue('│')}${' '.repeat(descPad)}${kleur.dim().white(desc)}${' '.repeat(descRightPad)}${kleur.blue('│')}`;
23
+
24
+ console.log();
25
+ console.log(topLine);
26
+ console.log(empty);
27
+ console.log(titleLine);
28
+ console.log(descLine);
29
+ console.log(empty);
30
+ console.log(bottomLine);
31
+ console.log();
32
+ };
5
33
 
6
34
  export const printSummary = (
7
35
  targetDir: string,
8
36
  template: TemplateType,
9
- blockCount: number,
10
- integrationCount: number,
37
+ selectedBlocks: string[],
38
+ selectedIntegrations: string[],
11
39
  uncoveredModules: string[] = [],
12
40
  skipInstall = false,
13
41
  ): void => {
14
42
  const templateName = TEMPLATES[template].name;
43
+ const relativeDir = path.relative(process.cwd(), targetDir) || '.';
15
44
 
16
- console.log();
17
- console.log(kleur.green().bold('Project created successfully!'));
18
- console.log();
19
- console.log(` Location: ${kleur.cyan(targetDir)}`);
20
- console.log(` Template: ${templateName}`);
21
- console.log(` Blocks: ${blockCount} blocks`);
22
- console.log(` Integrations: ${integrationCount} integrations`);
23
- console.log();
45
+ // Collect all content lines to measure max width
46
+ const lines: Array<{ text: string; plain: string }> = [];
47
+
48
+ const addLine = (text: string, plain: string): void => {
49
+ lines.push({ text, plain });
50
+ };
51
+ const addEmpty = (): void => {
52
+ lines.push({ text: '', plain: '' });
53
+ };
54
+
55
+ addLine(` ${kleur.green().bold('Project created successfully!')}`, ' Project created successfully!');
56
+ addEmpty();
57
+ addLine(` Location: ${kleur.cyan(`./${relativeDir}`)}`, ` Location: ./${relativeDir}`);
58
+ addLine(` Template: ${templateName}`, ` Template: ${templateName}`);
59
+ addEmpty();
60
+
61
+ addLine(
62
+ ` ${kleur.bold('Blocks')} ${kleur.dim(`(${selectedBlocks.length})`)}`,
63
+ ` Blocks (${selectedBlocks.length})`,
64
+ );
65
+ for (const block of selectedBlocks) {
66
+ addLine(` ${kleur.cyan('•')} ${block}`, ` • ${block}`);
67
+ }
68
+ addEmpty();
69
+
70
+ addLine(
71
+ ` ${kleur.bold('Integrations')} ${kleur.dim(`(${selectedIntegrations.length})`)}`,
72
+ ` Integrations (${selectedIntegrations.length})`,
73
+ );
74
+ for (const integration of selectedIntegrations) {
75
+ addLine(` ${kleur.yellow('•')} ${integration}`, ` • ${integration}`);
76
+ }
24
77
 
25
78
  if (uncoveredModules.length > 0) {
26
- console.log(kleur.yellow().bold('⚠ Warning: the following modules have no integration assigned:'));
27
- console.log();
79
+ addEmpty();
80
+ addLine(` ${kleur.yellow().bold('⚠ Uncovered modules')}`, ' ⚠ Uncovered modules');
28
81
  for (const mod of uncoveredModules) {
29
- console.log(kleur.yellow(` - ${mod}`));
82
+ addLine(` ${kleur.red('•')} ${mod}`, ` • ${mod}`);
30
83
  }
31
- console.log();
32
- console.log(kleur.red(' The project will NOT start until these modules are configured.'));
33
- console.log(' To fix this, edit packages/configs/integrations/src/models/<module>.ts');
34
- console.log(' and replace the @o2s/integrations.mocked import with a real integration.');
35
- console.log();
36
- console.log(kleur.bold('Next steps:'));
37
- console.log();
38
- console.log(` cd ${targetDir}`);
39
- console.log(kleur.dim(' # 1. Configure the modules listed above'));
40
- console.log(kleur.dim(' # 2. Add the required env vars to apps/api-harmonization/.env.local'));
41
- console.log(kleur.dim(' # 3. npm run dev'));
84
+ addEmpty();
85
+ addLine(
86
+ ` ${kleur.red('The project will NOT start until these are configured.')}`,
87
+ ' The project will NOT start until these are configured.',
88
+ );
89
+ addLine(
90
+ ` ${kleur.dim('Edit packages/configs/integrations/src/models/<module>.ts')}`,
91
+ ' Edit packages/configs/integrations/src/models/<module>.ts',
92
+ );
93
+ }
94
+
95
+ addEmpty();
96
+ addLine(` ${kleur.bold('Next steps:')}`, ' Next steps:');
97
+ addEmpty();
98
+ addLine(` ${kleur.white(`cd ./${relativeDir}`)}`, ` cd ./${relativeDir}`);
99
+
100
+ if (uncoveredModules.length > 0) {
101
+ addLine(
102
+ ` ${kleur.dim('# 1. Configure the uncovered modules above')}`,
103
+ ' # 1. Configure the uncovered modules above',
104
+ );
105
+ addLine(
106
+ ` ${kleur.dim('# 2. Add required env vars to apps/api-harmonization/.env.local')}`,
107
+ ' # 2. Add required env vars to apps/api-harmonization/.env.local',
108
+ );
109
+ addLine(
110
+ ` ${kleur.dim('# 3. Start development (two terminals):')}`,
111
+ ' # 3. Start development (two terminals):',
112
+ );
113
+ addLine(` ${kleur.dim('npm run watch:deps')}`, ' npm run watch:deps');
114
+ addLine(` ${kleur.dim('npm run watch:apps')}`, ' npm run watch:apps');
42
115
  } else {
43
- console.log(kleur.bold('Next steps:'));
44
- console.log();
45
- console.log(` cd ${targetDir}`);
46
116
  if (skipInstall) {
47
- console.log(kleur.dim(' # Install dependencies (npm install was skipped)'));
48
- console.log(' npm install');
117
+ addLine(
118
+ ` ${kleur.dim('# Install dependencies (npm install was skipped)')}`,
119
+ ' # Install dependencies (npm install was skipped)',
120
+ );
121
+ addLine(' npm install', ' npm install');
49
122
  }
50
- console.log(' npm run dev');
123
+ addLine(
124
+ ` npm run watch:deps ${kleur.dim('# Terminal 1: watch & build packages')}`,
125
+ ' npm run watch:deps # Terminal 1: watch & build packages',
126
+ );
127
+ addLine(
128
+ ` npm run watch:apps ${kleur.dim('# Terminal 2: run frontend + API')}`,
129
+ ' npm run watch:apps # Terminal 2: run frontend + API',
130
+ );
51
131
  }
52
132
 
133
+ addEmpty();
134
+ addLine(` ${kleur.bold('Useful links:')}`, ' Useful links:');
135
+ addLine(
136
+ ` ${kleur.dim('Docs & installation:')} ${kleur.cyan(DOCS_URL)}`,
137
+ ` Docs & installation: ${DOCS_URL}`,
138
+ );
139
+ addLine(
140
+ ` ${kleur.dim('Storybook (blocks):')} ${kleur.cyan(STORYBOOK_URL)}`,
141
+ ` Storybook (blocks): ${STORYBOOK_URL}`,
142
+ );
143
+ addLine(
144
+ ` ${kleur.dim('Integrations guide:')} ${kleur.cyan(DOCS_INTEGRATIONS_URL)}`,
145
+ ` Integrations guide: ${DOCS_INTEGRATIONS_URL}`,
146
+ );
147
+
148
+ // Calculate box width
149
+ const maxPlainWidth = Math.max(...lines.map((l) => l.plain.length));
150
+ const boxWidth = maxPlainWidth + 4; // 2 padding each side
151
+
152
+ // Print box
53
153
  console.log();
54
- console.log(kleur.bold('Documentation:'));
55
- console.log(kleur.cyan(` ${DOCS_URL}`));
154
+ console.log(` ${kleur.blue('╭' + '─'.repeat(boxWidth) + '╮')}`);
155
+
156
+ for (const line of lines) {
157
+ const rightPad = boxWidth - line.plain.length;
158
+ console.log(` ${kleur.blue('│')}${line.text}${' '.repeat(rightPad)}${kleur.blue('│')}`);
159
+ }
160
+
161
+ console.log(` ${kleur.blue('╰' + '─'.repeat(boxWidth) + '╯')}`);
56
162
  console.log();
57
163
  };
58
164
 
@@ -95,10 +95,30 @@ export const runWizardPrompts = async (
95
95
  let selectedIntegrations: string[];
96
96
 
97
97
  if (template === 'custom') {
98
+ const tipLines = [
99
+ `${kleur.blue().bold('Tip:')} Not sure which blocks to pick?`,
100
+ `Browse our Storybook to preview all available components:`,
101
+ kleur.cyan(STORYBOOK_URL),
102
+ ];
103
+ const tipWidth = Math.max(
104
+ 'Tip: Not sure which blocks to pick?'.length,
105
+ 'Browse our Storybook to preview all available components:'.length,
106
+ STORYBOOK_URL.length,
107
+ );
108
+ const boxWidth = tipWidth + 4;
109
+
98
110
  console.log();
99
- console.log(kleur.cyan().bold(' Tip:') + ' Not sure which blocks to pick?');
100
- console.log(` Browse our Storybook to preview all available components:`);
101
- console.log(kleur.cyan(` ${STORYBOOK_URL}`));
111
+ console.log(` ${kleur.blue('╭' + '─'.repeat(boxWidth) + '╮')}`);
112
+ console.log(
113
+ ` ${kleur.blue('│')} ${tipLines[0]}${' '.repeat(boxWidth - 2 - 'Tip: Not sure which blocks to pick?'.length)}${kleur.blue('│')}`,
114
+ );
115
+ console.log(
116
+ ` ${kleur.blue('│')} ${tipLines[1]}${' '.repeat(boxWidth - 2 - 'Browse our Storybook to preview all available components:'.length)}${kleur.blue('│')}`,
117
+ );
118
+ console.log(
119
+ ` ${kleur.blue('│')} ${tipLines[2]}${' '.repeat(boxWidth - 2 - STORYBOOK_URL.length)}${kleur.blue('│')}`,
120
+ );
121
+ console.log(` ${kleur.blue('╰' + '─'.repeat(boxWidth) + '╯')}`);
102
122
  console.log();
103
123
 
104
124
  selectedBlocks = await promptBlockSelection(availableBlocks, []);