@idealyst/cli 1.0.27 → 1.0.28
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/dist/index.js
CHANGED
|
@@ -52,7 +52,10 @@ async function copyTemplate(templatePath, destPath, data) {
|
|
|
52
52
|
await fs.copy(templatePath, destPath, {
|
|
53
53
|
filter: (src) => {
|
|
54
54
|
const relativePath = path.relative(templatePath, src);
|
|
55
|
-
|
|
55
|
+
// Skip App-with-trpc.tsx as it's only copied when tRPC is enabled
|
|
56
|
+
return !relativePath.includes('node_modules') &&
|
|
57
|
+
!relativePath.includes('.git') &&
|
|
58
|
+
!relativePath.endsWith('App-with-trpc.tsx');
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
61
|
// Process template files
|
|
@@ -134,10 +137,15 @@ function runCommand(command, args, options) {
|
|
|
134
137
|
});
|
|
135
138
|
});
|
|
136
139
|
}
|
|
137
|
-
function getTemplateData(projectName, description, appName) {
|
|
140
|
+
function getTemplateData(projectName, description, appName, workspaceScope) {
|
|
141
|
+
let packageName = createPackageName(projectName);
|
|
142
|
+
// If we have a workspace scope, prefix the package name with it
|
|
143
|
+
if (workspaceScope) {
|
|
144
|
+
packageName = `@${workspaceScope}/${packageName}`;
|
|
145
|
+
}
|
|
138
146
|
return {
|
|
139
147
|
projectName,
|
|
140
|
-
packageName
|
|
148
|
+
packageName,
|
|
141
149
|
version: '1.0.0',
|
|
142
150
|
description: description || `A new Idealyst project: ${projectName}`,
|
|
143
151
|
appName
|
|
@@ -159,6 +167,22 @@ async function isWorkspaceRoot(directory) {
|
|
|
159
167
|
}
|
|
160
168
|
return false;
|
|
161
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Gets the workspace name from the workspace root's package.json
|
|
172
|
+
*/
|
|
173
|
+
async function getWorkspaceName(directory) {
|
|
174
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
175
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
176
|
+
try {
|
|
177
|
+
const packageJson = await fs.readJSON(packageJsonPath);
|
|
178
|
+
return packageJson.name || null;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
162
186
|
/**
|
|
163
187
|
* Resolves the correct project path for individual projects (native, web, shared).
|
|
164
188
|
* Individual projects can ONLY be created within an existing workspace.
|
|
@@ -172,12 +196,15 @@ async function resolveProjectPath(projectName, directory) {
|
|
|
172
196
|
`Please first create a workspace with: idealyst init my-workspace\n` +
|
|
173
197
|
`Then navigate to the workspace directory and create your project.`);
|
|
174
198
|
}
|
|
199
|
+
// Get the workspace name to use as scope
|
|
200
|
+
const workspaceScope = await getWorkspaceName(directory);
|
|
175
201
|
// Create project in workspace's packages/ folder
|
|
176
202
|
const packagesDir = path.join(directory, 'packages');
|
|
177
203
|
await fs.ensureDir(packagesDir);
|
|
178
204
|
return {
|
|
179
205
|
projectPath: path.join(packagesDir, projectName),
|
|
180
|
-
workspacePath: `packages/${projectName}
|
|
206
|
+
workspacePath: `packages/${projectName}`,
|
|
207
|
+
workspaceScope
|
|
181
208
|
};
|
|
182
209
|
}
|
|
183
210
|
async function initializeReactNativeProject(projectName, directory, displayName, skipInstall) {
|
|
@@ -219,9 +246,11 @@ async function overlayIdealystFiles(templatePath, projectPath, data) {
|
|
|
219
246
|
filter: (src) => {
|
|
220
247
|
const relativePath = path.relative(templatePath, src);
|
|
221
248
|
// Skip package.json as we'll merge it separately
|
|
249
|
+
// Skip App-with-trpc.tsx as it's only copied when tRPC is enabled
|
|
222
250
|
return !relativePath.includes('node_modules') &&
|
|
223
251
|
!relativePath.includes('.git') &&
|
|
224
|
-
!relativePath.endsWith('package.json')
|
|
252
|
+
!relativePath.endsWith('package.json') &&
|
|
253
|
+
!relativePath.endsWith('App-with-trpc.tsx');
|
|
225
254
|
}
|
|
226
255
|
});
|
|
227
256
|
// Process template files
|
|
@@ -444,6 +473,7 @@ var utils = /*#__PURE__*/Object.freeze({
|
|
|
444
473
|
copyTrpcFiles: copyTrpcFiles,
|
|
445
474
|
createPackageName: createPackageName,
|
|
446
475
|
getTemplateData: getTemplateData,
|
|
476
|
+
getWorkspaceName: getWorkspaceName,
|
|
447
477
|
initializeReactNativeProject: initializeReactNativeProject,
|
|
448
478
|
installDependencies: installDependencies,
|
|
449
479
|
isWorkspaceRoot: isWorkspaceRoot,
|
|
@@ -472,9 +502,9 @@ async function generateNativeProject(options) {
|
|
|
472
502
|
const displayName = appName || name.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ');
|
|
473
503
|
console.log(chalk.blue(`📱 Creating React Native project: ${name}`));
|
|
474
504
|
console.log(chalk.gray(` App display name: ${displayName}`));
|
|
475
|
-
const { projectPath, workspacePath } = await resolveProjectPath(name, directory);
|
|
505
|
+
const { projectPath, workspacePath, workspaceScope } = await resolveProjectPath(name, directory);
|
|
476
506
|
const templatePath = path.join(__dirname$4, '..', 'templates', 'native');
|
|
477
|
-
const templateData = getTemplateData(name, `React Native app built with Idealyst Framework`, displayName);
|
|
507
|
+
const templateData = getTemplateData(name, `React Native app built with Idealyst Framework`, displayName, workspaceScope || undefined);
|
|
478
508
|
try {
|
|
479
509
|
// Step 1: Update workspace configuration FIRST (before React Native CLI)
|
|
480
510
|
await updateWorkspacePackageJson(workspacePath, directory);
|
|
@@ -530,9 +560,9 @@ async function generateWebProject(options) {
|
|
|
530
560
|
throw new Error(`Invalid project name: ${name}`);
|
|
531
561
|
}
|
|
532
562
|
console.log(chalk.blue(`🌐 Creating React Web project: ${name}`));
|
|
533
|
-
const { projectPath, workspacePath } = await resolveProjectPath(name, directory);
|
|
563
|
+
const { projectPath, workspacePath, workspaceScope } = await resolveProjectPath(name, directory);
|
|
534
564
|
const templatePath = path.join(__dirname$3, '..', 'templates', 'web');
|
|
535
|
-
const templateData = getTemplateData(name, `React web app built with Idealyst Framework
|
|
565
|
+
const templateData = getTemplateData(name, `React web app built with Idealyst Framework`, undefined, workspaceScope || undefined);
|
|
536
566
|
await copyTemplate(templatePath, projectPath, templateData);
|
|
537
567
|
// Handle tRPC setup
|
|
538
568
|
if (withTrpc) {
|
|
@@ -569,9 +599,9 @@ async function generateSharedLibrary(options) {
|
|
|
569
599
|
throw new Error(`Invalid project name: ${name}`);
|
|
570
600
|
}
|
|
571
601
|
console.log(chalk.blue(`📦 Creating shared library: ${name}`));
|
|
572
|
-
const { projectPath, workspacePath } = await resolveProjectPath(name, directory);
|
|
602
|
+
const { projectPath, workspacePath, workspaceScope } = await resolveProjectPath(name, directory);
|
|
573
603
|
const templatePath = path.join(__dirname$2, '..', 'templates', 'shared');
|
|
574
|
-
const templateData = getTemplateData(name, `Shared library built with Idealyst Framework
|
|
604
|
+
const templateData = getTemplateData(name, `Shared library built with Idealyst Framework`, undefined, workspaceScope || undefined);
|
|
575
605
|
await copyTemplate(templatePath, projectPath, templateData);
|
|
576
606
|
await installDependencies(projectPath, skipInstall);
|
|
577
607
|
await updateWorkspacePackageJson(workspacePath, directory);
|
|
@@ -614,9 +644,9 @@ async function generateApiProject(options) {
|
|
|
614
644
|
throw new Error(`Invalid project name: ${name}`);
|
|
615
645
|
}
|
|
616
646
|
console.log(chalk.blue(`🚀 Creating API project: ${name}`));
|
|
617
|
-
const { projectPath, workspacePath } = await resolveProjectPath(name, directory);
|
|
647
|
+
const { projectPath, workspacePath, workspaceScope } = await resolveProjectPath(name, directory);
|
|
618
648
|
const templatePath = path.join(__dirname, '..', 'templates', 'api');
|
|
619
|
-
const templateData = getTemplateData(name, `Clean API server template with tRPC, Prisma, and Zod
|
|
649
|
+
const templateData = getTemplateData(name, `Clean API server template with tRPC, Prisma, and Zod`, undefined, workspaceScope || undefined);
|
|
620
650
|
await copyTemplate(templatePath, projectPath, templateData);
|
|
621
651
|
await installDependencies(projectPath, skipInstall);
|
|
622
652
|
await updateWorkspacePackageJson(workspacePath, directory);
|
|
@@ -9,11 +9,15 @@ export declare function installDependencies(projectPath: string, skipInstall?: b
|
|
|
9
9
|
export declare function runCommand(command: string, args: string[], options: {
|
|
10
10
|
cwd: string;
|
|
11
11
|
}): Promise<void>;
|
|
12
|
-
export declare function getTemplateData(projectName: string, description?: string, appName?: string): TemplateData;
|
|
12
|
+
export declare function getTemplateData(projectName: string, description?: string, appName?: string, workspaceScope?: string): TemplateData;
|
|
13
13
|
/**
|
|
14
14
|
* Detects if we're in a workspace root directory
|
|
15
15
|
*/
|
|
16
16
|
export declare function isWorkspaceRoot(directory: string): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the workspace name from the workspace root's package.json
|
|
19
|
+
*/
|
|
20
|
+
export declare function getWorkspaceName(directory: string): Promise<string | null>;
|
|
17
21
|
/**
|
|
18
22
|
* Resolves the correct project path for individual projects (native, web, shared).
|
|
19
23
|
* Individual projects can ONLY be created within an existing workspace.
|
|
@@ -22,6 +26,7 @@ export declare function isWorkspaceRoot(directory: string): Promise<boolean>;
|
|
|
22
26
|
export declare function resolveProjectPath(projectName: string, directory: string): Promise<{
|
|
23
27
|
projectPath: string;
|
|
24
28
|
workspacePath: string;
|
|
29
|
+
workspaceScope: string | null;
|
|
25
30
|
}>;
|
|
26
31
|
export declare function initializeReactNativeProject(projectName: string, directory: string, displayName?: string, skipInstall?: boolean): Promise<void>;
|
|
27
32
|
export declare function overlayIdealystFiles(templatePath: string, projectPath: string, data: TemplateData): Promise<void>;
|
package/package.json
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
"description": "{{description}}",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"scripts": {
|
|
8
15
|
"build": "tsc",
|
|
9
16
|
"dev": "tsx watch src/server.ts",
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
3
|
import { httpBatchLink } from '@trpc/client';
|
|
4
|
-
import { UnistylesRegistry } from 'react-native-unistyles';
|
|
5
4
|
import { Screen, Text, View } from '@idealyst/components';
|
|
6
|
-
import { breakpoints, lightTheme, darkTheme } from '@idealyst/theme';
|
|
7
5
|
import { trpc } from './utils/trpc';
|
|
8
6
|
|
|
9
|
-
// Register the Unistyles themes and breakpoints
|
|
10
|
-
UnistylesRegistry
|
|
11
|
-
.addBreakpoints(breakpoints)
|
|
12
|
-
.addThemes({
|
|
13
|
-
light: lightTheme,
|
|
14
|
-
dark: darkTheme,
|
|
15
|
-
})
|
|
16
|
-
.addConfig({
|
|
17
|
-
adaptiveThemes: true,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
7
|
// Create tRPC client
|
|
21
8
|
const queryClient = new QueryClient();
|
|
22
9
|
|
|
@@ -1,22 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
3
|
import { httpBatchLink } from '@trpc/client';
|
|
4
|
-
import { UnistylesRegistry } from 'react-native-unistyles';
|
|
5
4
|
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
|
6
5
|
import { trpc } from './utils/trpc';
|
|
7
6
|
import { Screen, Text, View } from '@idealyst/components';
|
|
8
|
-
import { breakpoints, lightTheme, darkTheme } from '@idealyst/theme';
|
|
9
|
-
|
|
10
|
-
// Register the Unistyles themes and breakpoints
|
|
11
|
-
UnistylesRegistry
|
|
12
|
-
.addBreakpoints(breakpoints)
|
|
13
|
-
.addThemes({
|
|
14
|
-
light: lightTheme,
|
|
15
|
-
dark: darkTheme,
|
|
16
|
-
})
|
|
17
|
-
.addConfig({
|
|
18
|
-
adaptiveThemes: true,
|
|
19
|
-
});
|
|
20
7
|
|
|
21
8
|
// Create tRPC client
|
|
22
9
|
const queryClient = new QueryClient();
|