create-vista-app 0.2.1 → 0.2.3
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/bin/cli.js
CHANGED
|
@@ -15,25 +15,30 @@ function detectPackageManager() {
|
|
|
15
15
|
return 'npm';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const pkgManager = detectPackageManager();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
const pkgManager = detectPackageManager();
|
|
19
|
+
const rawArgs = process.argv.slice(2);
|
|
20
|
+
const useTypedApiStarter = rawArgs.includes('--typed-api') || rawArgs.includes('--typed');
|
|
21
|
+
const skipInstall = rawArgs.includes('--skip-install');
|
|
22
|
+
const skipGit = rawArgs.includes('--no-git');
|
|
23
|
+
|
|
24
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
25
|
+
console.log(`
|
|
26
|
+
Usage:
|
|
27
|
+
${usageCommand} [--typed-api] [--skip-install] [--no-git]
|
|
28
|
+
|
|
29
|
+
Example:
|
|
30
|
+
npx create-vista-app@latest my-vista-app
|
|
31
|
+
npx create-vista-app@latest my-vista-app --typed-api
|
|
32
|
+
`);
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Simple args: npx create-vista-app@latest <project-name>
|
|
37
|
+
const args = rawArgs.filter((arg) => !arg.startsWith('-'));
|
|
38
|
+
const projectName = args[0] || 'my-vista-app';
|
|
39
|
+
const useLocal = rawArgs.includes('--local');
|
|
40
|
+
const currentDir = process.cwd();
|
|
41
|
+
const projectDir = path.join(currentDir, projectName);
|
|
37
42
|
|
|
38
43
|
console.log(`Creating a new Vista app in ${projectDir}...`);
|
|
39
44
|
|
|
@@ -61,9 +66,15 @@ function copyRecursiveSync(src, dest) {
|
|
|
61
66
|
}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
copyRecursiveSync(templateDir, projectDir);
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
copyRecursiveSync(templateDir, projectDir);
|
|
70
|
+
|
|
71
|
+
if (useTypedApiStarter) {
|
|
72
|
+
const typedTemplateDir = path.join(__dirname, '../template-typed');
|
|
73
|
+
copyRecursiveSync(typedTemplateDir, projectDir);
|
|
74
|
+
console.log('Added typed API starter files.');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log('Scaffolding complete.');
|
|
67
78
|
|
|
68
79
|
// 3. Setup Dependencies (production-ready)
|
|
69
80
|
const packageJson = {
|
|
@@ -152,37 +163,45 @@ fs.writeFileSync(path.join(projectDir, '.gitignore'), gitignoreContent);
|
|
|
152
163
|
console.log('Created .gitignore');
|
|
153
164
|
|
|
154
165
|
// 5. Initialize Git Repository
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
console.log(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
166
|
+
if (!skipGit) {
|
|
167
|
+
try {
|
|
168
|
+
execSync('git init', { cwd: projectDir, stdio: 'pipe' });
|
|
169
|
+
execSync('git add .', { cwd: projectDir, stdio: 'pipe' });
|
|
170
|
+
execSync('git commit -m "Initial commit from create-vista-app"', {
|
|
171
|
+
cwd: projectDir,
|
|
172
|
+
stdio: 'pipe',
|
|
173
|
+
env: {
|
|
174
|
+
...process.env,
|
|
175
|
+
GIT_AUTHOR_NAME: 'Vista',
|
|
176
|
+
GIT_AUTHOR_EMAIL: 'vista@example.com',
|
|
177
|
+
GIT_COMMITTER_NAME: 'Vista',
|
|
178
|
+
GIT_COMMITTER_EMAIL: 'vista@example.com',
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
console.log('Initialized git repository with initial commit');
|
|
182
|
+
} catch (e) {
|
|
183
|
+
// Git might not be installed, that's okay
|
|
184
|
+
console.log('Note: Could not initialize git repository. You can do this manually with: git init');
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
console.log('Skipped git initialization (--no-git).');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 6. Install Dependencies
|
|
191
|
+
const installCmd = pkgManager === 'yarn' ? 'yarn' : `${pkgManager} install`;
|
|
192
|
+
if (!skipInstall) {
|
|
193
|
+
console.log(`\nInstalling dependencies with ${pkgManager}... This may take a moment.\n`);
|
|
194
|
+
try {
|
|
195
|
+
execSync(installCmd, { cwd: projectDir, stdio: 'inherit' });
|
|
196
|
+
console.log(`\n✓ Dependencies installed successfully!`);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
console.log(
|
|
199
|
+
`\nNote: Could not install dependencies automatically. Run "${installCmd}" manually.`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
console.log('\nSkipped dependency installation (--skip-install).');
|
|
204
|
+
}
|
|
186
205
|
|
|
187
206
|
const runCmd = pkgManager === 'npm' ? 'npm run' : pkgManager;
|
|
188
207
|
const createCmd =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-vista-app",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Create Vista applications with one command",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-vista-app": "./bin/cli.js"
|
|
@@ -21,12 +21,13 @@
|
|
|
21
21
|
],
|
|
22
22
|
"files": [
|
|
23
23
|
"bin",
|
|
24
|
-
"template"
|
|
24
|
+
"template",
|
|
25
|
+
"template-typed"
|
|
25
26
|
],
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"fs-extra": "^11.1.1",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
29
|
+
"picocolors": "^1.0.0",
|
|
30
|
+
"prompts": "^2.4.2"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/react": "^19.0.0",
|
package/template/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Built with [Vista.js](https://github.com/vistagen/Vista-Js) — the React framew
|
|
|
4
4
|
|
|
5
5
|
## Getting Started
|
|
6
6
|
|
|
7
|
-
Run the development server:
|
|
7
|
+
Run the development server:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm run dev
|
|
@@ -12,7 +12,13 @@ npm run dev
|
|
|
12
12
|
pnpm dev
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Open [http://localhost:3003](http://localhost:3003) in your browser.
|
|
15
|
+
Open [http://localhost:3003](http://localhost:3003) in your browser.
|
|
16
|
+
|
|
17
|
+
If you want typed API starter files in a fresh app:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx create-vista-app@latest my-vista-app --typed-api
|
|
21
|
+
```
|
|
16
22
|
|
|
17
23
|
## Project Structure
|
|
18
24
|
|
|
@@ -39,9 +45,24 @@ vista.config.ts # Framework configuration
|
|
|
39
45
|
|
|
40
46
|
| Command | Description |
|
|
41
47
|
| ------------- | --------------------------------- |
|
|
42
|
-
| `vista dev` | Start dev server with live-reload |
|
|
43
|
-
| `vista build` | Create production build |
|
|
44
|
-
| `vista start` | Start production server |
|
|
48
|
+
| `vista dev` | Start dev server with live-reload |
|
|
49
|
+
| `vista build` | Create production build |
|
|
50
|
+
| `vista start` | Start production server |
|
|
51
|
+
| `vista g api-init` | Generate typed API starter files |
|
|
52
|
+
| `vista g router <name>` | Generate a typed router file |
|
|
53
|
+
| `vista g procedure <name> [get\|post]` | Generate a typed procedure file |
|
|
54
|
+
|
|
55
|
+
## Typed API Rollback
|
|
56
|
+
|
|
57
|
+
Typed API is experimental and can be disabled anytime from `vista.config.ts`:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
experimental: {
|
|
61
|
+
typedApi: {
|
|
62
|
+
enabled: false
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
45
66
|
|
|
46
67
|
## Learn More
|
|
47
68
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
images: {
|
|
3
|
+
domains: ['example.com'],
|
|
4
|
+
},
|
|
5
|
+
experimental: {
|
|
6
|
+
typedApi: {
|
|
7
|
+
enabled: true,
|
|
8
|
+
serialization: 'json',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
// Optional: override server port
|
|
12
|
+
// server: {
|
|
13
|
+
// port: 3000
|
|
14
|
+
// }
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default config;
|