create-o2s-app 2.0.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-o2s-app",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "CLI tool to scaffold new O2S applications with Next.js and NestJS setup.",
package/src/constants.ts CHANGED
@@ -15,7 +15,9 @@ export const ALWAYS_REMOVE_DIRS: string[] = [
15
15
  '.github',
16
16
  '.changeset',
17
17
  'apps/docs',
18
+ 'packages/blocks',
18
19
  'packages/framework',
20
+ 'packages/integrations',
19
21
  'packages/modules',
20
22
  'packages/utils',
21
23
  'packages/cli',
@@ -1,20 +1,10 @@
1
- import { ALWAYS_REMOVE_DIRS, ALWAYS_REMOVE_FILES, BLOCKS_PATH, INTEGRATIONS_PATH } from '../constants';
1
+ import { ALWAYS_REMOVE_DIRS, ALWAYS_REMOVE_FILES } from '../constants';
2
2
  import * as fs from 'fs-extra';
3
3
  import * as path from 'path';
4
4
 
5
- export const cleanupProject = async (
6
- projectDir: string,
7
- selectedBlockNames: string[],
8
- selectedIntegrationNames: string[],
9
- ): Promise<void> => {
5
+ export const cleanupProject = async (projectDir: string): Promise<void> => {
10
6
  console.log('Organizing project structure...');
11
7
 
12
- await removeAlwaysRemovedPaths(projectDir);
13
- await removeUnselectedBlocks(projectDir, selectedBlockNames);
14
- await removeUnselectedIntegrations(projectDir, selectedIntegrationNames);
15
- };
16
-
17
- const removeAlwaysRemovedPaths = async (projectDir: string): Promise<void> => {
18
8
  for (const dir of ALWAYS_REMOVE_DIRS) {
19
9
  const fullPath = path.join(projectDir, dir);
20
10
  if (await fs.pathExists(fullPath)) {
@@ -29,35 +19,3 @@ const removeAlwaysRemovedPaths = async (projectDir: string): Promise<void> => {
29
19
  }
30
20
  }
31
21
  };
32
-
33
- const removeUnselectedBlocks = async (projectDir: string, selectedBlockNames: string[]): Promise<void> => {
34
- const blocksDir = path.join(projectDir, BLOCKS_PATH);
35
-
36
- if (!(await fs.pathExists(blocksDir))) return;
37
-
38
- const entries = await fs.readdir(blocksDir, { withFileTypes: true });
39
-
40
- for (const entry of entries) {
41
- if (!entry.isDirectory()) continue;
42
-
43
- if (!selectedBlockNames.includes(entry.name)) {
44
- await fs.remove(path.join(blocksDir, entry.name));
45
- }
46
- }
47
- };
48
-
49
- const removeUnselectedIntegrations = async (projectDir: string, selectedIntegrationNames: string[]): Promise<void> => {
50
- const integrationsDir = path.join(projectDir, INTEGRATIONS_PATH);
51
-
52
- if (!(await fs.pathExists(integrationsDir))) return;
53
-
54
- const entries = await fs.readdir(integrationsDir, { withFileTypes: true });
55
-
56
- for (const entry of entries) {
57
- if (!entry.isDirectory()) continue;
58
-
59
- if (!selectedIntegrationNames.includes(entry.name)) {
60
- await fs.remove(path.join(integrationsDir, entry.name));
61
- }
62
- }
63
- };
@@ -33,8 +33,8 @@ export const scaffold = async (
33
33
  console.log(`Creating project in "${targetDir}"...`);
34
34
  await fs.move(tempDir, targetDir);
35
35
 
36
- // Step 2: Remove unneeded directories
37
- await cleanupProject(targetDir, selectedBlocks, selectedIntegrations);
36
+ // Step 2: Remove unneeded directories (all packages/* are removed; deps come from npm registry)
37
+ await cleanupProject(targetDir);
38
38
 
39
39
  // Step 3: Remove unselected block/integration references from app source files
40
40
  console.log('Configuring project for selected blocks...');
@@ -3,6 +3,16 @@ import * as path from 'path';
3
3
 
4
4
  const APP_PACKAGE_JSON_PATHS = ['apps/api-harmonization/package.json', 'apps/frontend/package.json'];
5
5
 
6
+ // Private workspace-only packages that are not published to npm and should be
7
+ // removed from scaffolded projects (they are part of the monorepo dev setup).
8
+ const PRIVATE_PACKAGES = [
9
+ '@o2s/eslint-config',
10
+ '@o2s/lint-staged-config',
11
+ '@o2s/prettier-config',
12
+ '@o2s/typescript-config',
13
+ '@o2s/vitest-config',
14
+ ];
15
+
6
16
  export const transformAppsPackageJson = async (
7
17
  projectDir: string,
8
18
  selectedBlockNames: string[],
@@ -15,21 +25,31 @@ export const transformAppsPackageJson = async (
15
25
 
16
26
  const packageJson = await fs.readJson(filePath);
17
27
 
18
- if (packageJson.dependencies) {
19
- for (const depName of Object.keys(packageJson.dependencies)) {
28
+ for (const section of ['dependencies', 'devDependencies'] as const) {
29
+ if (!packageJson[section]) continue;
30
+
31
+ for (const depName of Object.keys(packageJson[section])) {
32
+ // Remove private workspace-only packages
33
+ if (PRIVATE_PACKAGES.includes(depName)) {
34
+ delete packageJson[section][depName];
35
+ continue;
36
+ }
37
+
38
+ // Remove unselected blocks
20
39
  const blockMatch = depName.match(/^@o2s\/blocks\.(.+)$/);
21
40
  if (blockMatch && blockMatch[1] && !selectedBlockNames.includes(blockMatch[1])) {
22
- delete packageJson.dependencies[depName];
41
+ delete packageJson[section][depName];
23
42
  continue;
24
43
  }
25
44
 
45
+ // Remove unselected integrations
26
46
  const integrationMatch = depName.match(/^@o2s\/integrations\.(.+)$/);
27
47
  if (
28
48
  integrationMatch &&
29
49
  integrationMatch[1] &&
30
50
  !selectedIntegrationNames.includes(integrationMatch[1])
31
51
  ) {
32
- delete packageJson.dependencies[depName];
52
+ delete packageJson[section][depName];
33
53
  }
34
54
  }
35
55
  }
@@ -31,11 +31,7 @@ const buildModuleIntegrationMap = (
31
31
  return moduleMap;
32
32
  };
33
33
 
34
- const updateConfigsPackageJson = async (
35
- projectDir: string,
36
- selectedIntegrations: string[],
37
- integrationModules: Record<string, string[]>,
38
- ): Promise<void> => {
34
+ const updateConfigsPackageJson = async (projectDir: string, selectedIntegrations: string[]): Promise<void> => {
39
35
  const pkgPath = path.join(projectDir, CONFIGS_PACKAGE_JSON_PATH);
40
36
 
41
37
  if (!(await fs.pathExists(pkgPath))) return;
@@ -52,13 +48,6 @@ const updateConfigsPackageJson = async (
52
48
  }
53
49
  }
54
50
 
55
- // Add deps for selected integrations that have module mappings
56
- for (const integration of selectedIntegrations) {
57
- if (integrationModules[integration]?.length) {
58
- pkg.dependencies[`@o2s/integrations.${integration}`] = '*';
59
- }
60
- }
61
-
62
51
  await fs.writeJson(pkgPath, pkg, { spaces: 4 });
63
52
  };
64
53
 
@@ -91,7 +80,7 @@ export const transformIntegrationConfigs = async (
91
80
  await fs.writeFile(filePath, updatedContent, 'utf-8');
92
81
  }
93
82
 
94
- await updateConfigsPackageJson(projectDir, selectedIntegrations, integrationModules);
83
+ await updateConfigsPackageJson(projectDir, selectedIntegrations);
95
84
 
96
85
  // Detect model files that still import mocked but mocked is not selected.
97
86
  // Skip only when 'mocked' (full) is selected — it covers all modules.