@svton/cli 1.0.5 → 1.0.7
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 +148 -75
- package/dist/index.mjs +148 -75
- package/package.json +1 -2
- package/templates/apps/admin/next-env.d.ts +0 -2
- package/templates/apps/admin/next.config.js +0 -15
- package/templates/apps/admin/package.json.tpl +0 -54
- package/templates/apps/admin/postcss.config.js +0 -6
- package/templates/apps/admin/src/app/globals.css +0 -37
- package/templates/apps/admin/src/app/layout.tsx +0 -19
- package/templates/apps/admin/src/app/login/page.tsx +0 -96
- package/templates/apps/admin/src/app/page.tsx +0 -8
- package/templates/apps/admin/src/app/users/page.tsx +0 -165
- package/templates/apps/admin/src/components/ui/switch.tsx +0 -29
- package/templates/apps/admin/src/hooks/useAPI.ts +0 -130
- package/templates/apps/admin/src/lib/api-client.ts +0 -100
- package/templates/apps/admin/tailwind.config.js +0 -54
- package/templates/apps/admin/tsconfig.json +0 -22
- package/templates/apps/backend/.env.example +0 -14
- package/templates/apps/backend/nest-cli.json +0 -8
- package/templates/apps/backend/package.json.tpl +0 -57
- package/templates/apps/backend/prisma/schema.prisma +0 -72
- package/templates/apps/backend/prisma/seed.ts +0 -32
- package/templates/apps/backend/src/app.controller.ts +0 -15
- package/templates/apps/backend/src/app.module.ts +0 -19
- package/templates/apps/backend/src/app.service.ts +0 -12
- package/templates/apps/backend/src/auth/auth.controller.ts +0 -31
- package/templates/apps/backend/src/auth/auth.module.ts +0 -27
- package/templates/apps/backend/src/auth/auth.service.ts +0 -89
- package/templates/apps/backend/src/auth/jwt-auth.guard.ts +0 -5
- package/templates/apps/backend/src/auth/jwt.strategy.ts +0 -27
- package/templates/apps/backend/src/main.ts +0 -40
- package/templates/apps/backend/src/prisma/prisma.module.ts +0 -9
- package/templates/apps/backend/src/prisma/prisma.service.ts +0 -13
- package/templates/apps/backend/src/user/user.controller.ts +0 -50
- package/templates/apps/backend/src/user/user.module.ts +0 -12
- package/templates/apps/backend/src/user/user.service.ts +0 -117
- package/templates/apps/backend/tsconfig.json +0 -23
- package/templates/apps/mobile/babel.config.js +0 -8
- package/templates/apps/mobile/config/index.ts +0 -65
- package/templates/apps/mobile/package.json.tpl +0 -48
- package/templates/apps/mobile/project.config.json.tpl +0 -17
- package/templates/apps/mobile/src/app.config.ts +0 -9
- package/templates/apps/mobile/src/app.scss +0 -4
- package/templates/apps/mobile/src/app.ts +0 -8
- package/templates/apps/mobile/src/pages/index/index.scss +0 -7
- package/templates/apps/mobile/src/pages/index/index.tsx +0 -49
- package/templates/apps/mobile/tsconfig.json +0 -21
- package/templates/packages/types/package.json.tpl +0 -16
- package/templates/packages/types/src/api.ts +0 -88
- package/templates/packages/types/src/common.ts +0 -89
- package/templates/packages/types/src/index.ts +0 -3
- package/templates/packages/types/tsconfig.json +0 -16
package/dist/index.js
CHANGED
|
@@ -40,12 +40,12 @@ var import_commander = require("commander");
|
|
|
40
40
|
var import_inquirer = __toESM(require("inquirer"));
|
|
41
41
|
var import_chalk2 = __toESM(require("chalk"));
|
|
42
42
|
var import_ora = __toESM(require("ora"));
|
|
43
|
-
var
|
|
44
|
-
var
|
|
43
|
+
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
44
|
+
var import_path3 = __toESM(require("path"));
|
|
45
45
|
var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
|
|
46
46
|
|
|
47
47
|
// src/utils/template.ts
|
|
48
|
-
var
|
|
48
|
+
var import_fs_extra3 = __toESM(require("fs-extra"));
|
|
49
49
|
|
|
50
50
|
// src/utils/logger.ts
|
|
51
51
|
var import_chalk = __toESM(require("chalk"));
|
|
@@ -70,22 +70,84 @@ var logger = {
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
// src/utils/copy-template.ts
|
|
73
|
+
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
74
|
+
var import_path2 = __toESM(require("path"));
|
|
75
|
+
|
|
76
|
+
// src/utils/github-template.ts
|
|
73
77
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
74
78
|
var import_path = __toESM(require("path"));
|
|
79
|
+
var import_child_process = require("child_process");
|
|
80
|
+
var import_os = __toESM(require("os"));
|
|
81
|
+
var GITHUB_REPO = "751848178/svton";
|
|
82
|
+
var GITHUB_BRANCH = "main";
|
|
83
|
+
async function downloadTemplateFromGitHub(options = {}) {
|
|
84
|
+
const repo = options.repo || GITHUB_REPO;
|
|
85
|
+
const branch = options.branch || GITHUB_BRANCH;
|
|
86
|
+
const tempDir = import_path.default.join(import_os.default.tmpdir(), `svton-template-${Date.now()}`);
|
|
87
|
+
const archiveUrl = `https://github.com/${repo}/archive/refs/heads/${branch}.tar.gz`;
|
|
88
|
+
logger.debug(`Downloading template from GitHub: ${archiveUrl}`);
|
|
89
|
+
try {
|
|
90
|
+
await import_fs_extra.default.ensureDir(tempDir);
|
|
91
|
+
const tarFile = import_path.default.join(tempDir, "template.tar.gz");
|
|
92
|
+
(0, import_child_process.execSync)(`curl -sL "${archiveUrl}" -o "${tarFile}"`, {
|
|
93
|
+
stdio: "pipe"
|
|
94
|
+
});
|
|
95
|
+
(0, import_child_process.execSync)(`tar -xzf "${tarFile}" -C "${tempDir}"`, {
|
|
96
|
+
stdio: "pipe"
|
|
97
|
+
});
|
|
98
|
+
await import_fs_extra.default.remove(tarFile);
|
|
99
|
+
const repoName = repo.split("/")[1];
|
|
100
|
+
const extractedDir = import_path.default.join(tempDir, `${repoName}-${branch}`);
|
|
101
|
+
const templateDir = import_path.default.join(extractedDir, "templates");
|
|
102
|
+
if (await import_fs_extra.default.pathExists(templateDir)) {
|
|
103
|
+
logger.debug(`Template downloaded to: ${templateDir}`);
|
|
104
|
+
return templateDir;
|
|
105
|
+
}
|
|
106
|
+
throw new Error("Templates directory not found in downloaded repository");
|
|
107
|
+
} catch (error) {
|
|
108
|
+
await import_fs_extra.default.remove(tempDir).catch(() => {
|
|
109
|
+
});
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function cleanupTemplateDir(templateDir) {
|
|
114
|
+
try {
|
|
115
|
+
const tempRoot = import_path.default.dirname(import_path.default.dirname(templateDir));
|
|
116
|
+
if (tempRoot.includes("svton-template-")) {
|
|
117
|
+
await import_fs_extra.default.remove(tempRoot);
|
|
118
|
+
logger.debug(`Cleaned up temp directory: ${tempRoot}`);
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
logger.debug(`Failed to cleanup temp directory: ${error}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/utils/copy-template.ts
|
|
75
126
|
async function copyTemplateFiles(config) {
|
|
76
127
|
const { template, projectPath } = config;
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
128
|
+
let templateDir = null;
|
|
129
|
+
let needCleanup = false;
|
|
130
|
+
const cliPackageRoot = import_path2.default.dirname(__dirname);
|
|
131
|
+
const frameworkRoot = import_path2.default.dirname(import_path2.default.dirname(cliPackageRoot));
|
|
132
|
+
const localTemplateDir = import_path2.default.join(frameworkRoot, "templates");
|
|
133
|
+
if (await import_fs_extra2.default.pathExists(localTemplateDir)) {
|
|
134
|
+
templateDir = localTemplateDir;
|
|
135
|
+
logger.debug(`Using local template directory: ${templateDir}`);
|
|
82
136
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
137
|
+
if (!templateDir) {
|
|
138
|
+
logger.info("Downloading templates from GitHub...");
|
|
139
|
+
try {
|
|
140
|
+
templateDir = await downloadTemplateFromGitHub();
|
|
141
|
+
needCleanup = true;
|
|
142
|
+
logger.info("Templates downloaded successfully");
|
|
143
|
+
} catch (error) {
|
|
144
|
+
logger.warn(`Failed to download templates from GitHub: ${error}`);
|
|
145
|
+
logger.warn("Using built-in minimal templates");
|
|
146
|
+
await copyBuiltInTemplates(config);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
88
149
|
}
|
|
150
|
+
logger.debug(`Copying template files from: ${templateDir}`);
|
|
89
151
|
const originalCwd = process.cwd();
|
|
90
152
|
process.chdir(projectPath);
|
|
91
153
|
try {
|
|
@@ -94,32 +156,35 @@ async function copyTemplateFiles(config) {
|
|
|
94
156
|
await copyBackendTemplate(templateDir, config);
|
|
95
157
|
await copyAdminTemplate(templateDir, config);
|
|
96
158
|
await copyMobileTemplate(templateDir, config);
|
|
97
|
-
await
|
|
159
|
+
await copySharedPackages(templateDir, config);
|
|
98
160
|
break;
|
|
99
161
|
case "backend-only":
|
|
100
162
|
await copyBackendTemplate(templateDir, config);
|
|
101
|
-
await
|
|
163
|
+
await copySharedPackages(templateDir, config);
|
|
102
164
|
break;
|
|
103
165
|
case "admin-only":
|
|
104
166
|
await copyAdminTemplate(templateDir, config);
|
|
105
|
-
await
|
|
167
|
+
await copySharedPackages(templateDir, config);
|
|
106
168
|
break;
|
|
107
169
|
case "mobile-only":
|
|
108
170
|
await copyMobileTemplate(templateDir, config);
|
|
109
|
-
await
|
|
171
|
+
await copySharedPackages(templateDir, config);
|
|
110
172
|
break;
|
|
111
173
|
}
|
|
112
174
|
} finally {
|
|
113
175
|
process.chdir(originalCwd);
|
|
176
|
+
if (needCleanup && templateDir) {
|
|
177
|
+
await cleanupTemplateDir(templateDir);
|
|
178
|
+
}
|
|
114
179
|
}
|
|
115
180
|
}
|
|
116
181
|
async function copyBackendTemplate(sourceDir, config) {
|
|
117
|
-
const sourcePath =
|
|
182
|
+
const sourcePath = import_path2.default.join(sourceDir, "apps/backend");
|
|
118
183
|
const destPath = "apps/backend";
|
|
119
|
-
await
|
|
120
|
-
await
|
|
184
|
+
await import_fs_extra2.default.ensureDir(destPath);
|
|
185
|
+
await import_fs_extra2.default.copy(sourcePath, destPath, {
|
|
121
186
|
filter: (src) => {
|
|
122
|
-
const relativePath =
|
|
187
|
+
const relativePath = import_path2.default.relative(sourcePath, src);
|
|
123
188
|
return !relativePath.includes("node_modules") && !relativePath.includes("dist") && !relativePath.includes(".env") && !relativePath.includes(".env.local");
|
|
124
189
|
}
|
|
125
190
|
});
|
|
@@ -127,12 +192,12 @@ async function copyBackendTemplate(sourceDir, config) {
|
|
|
127
192
|
logger.debug("Backend template copied");
|
|
128
193
|
}
|
|
129
194
|
async function copyAdminTemplate(sourceDir, config) {
|
|
130
|
-
const sourcePath =
|
|
195
|
+
const sourcePath = import_path2.default.join(sourceDir, "apps/admin");
|
|
131
196
|
const destPath = "apps/admin";
|
|
132
|
-
await
|
|
133
|
-
await
|
|
197
|
+
await import_fs_extra2.default.ensureDir(destPath);
|
|
198
|
+
await import_fs_extra2.default.copy(sourcePath, destPath, {
|
|
134
199
|
filter: (src) => {
|
|
135
|
-
const relativePath =
|
|
200
|
+
const relativePath = import_path2.default.relative(sourcePath, src);
|
|
136
201
|
return !relativePath.includes("node_modules") && !relativePath.includes(".next") && !relativePath.includes(".env.local");
|
|
137
202
|
}
|
|
138
203
|
});
|
|
@@ -140,44 +205,52 @@ async function copyAdminTemplate(sourceDir, config) {
|
|
|
140
205
|
logger.debug("Admin template copied");
|
|
141
206
|
}
|
|
142
207
|
async function copyMobileTemplate(sourceDir, config) {
|
|
143
|
-
const sourcePath =
|
|
208
|
+
const sourcePath = import_path2.default.join(sourceDir, "apps/mobile");
|
|
144
209
|
const destPath = "apps/mobile";
|
|
145
|
-
await
|
|
146
|
-
await
|
|
210
|
+
await import_fs_extra2.default.ensureDir(destPath);
|
|
211
|
+
await import_fs_extra2.default.copy(sourcePath, destPath, {
|
|
147
212
|
filter: (src) => {
|
|
148
|
-
const relativePath =
|
|
213
|
+
const relativePath = import_path2.default.relative(sourcePath, src);
|
|
149
214
|
return !relativePath.includes("node_modules") && !relativePath.includes("dist");
|
|
150
215
|
}
|
|
151
216
|
});
|
|
152
217
|
await replacePackageNames(destPath, config);
|
|
153
218
|
logger.debug("Mobile template copied");
|
|
154
219
|
}
|
|
155
|
-
async function
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
await
|
|
159
|
-
await
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
220
|
+
async function copySharedPackages(sourceDir, config) {
|
|
221
|
+
const packagesSourceDir = import_path2.default.join(sourceDir, "packages");
|
|
222
|
+
const packagesDestDir = "packages";
|
|
223
|
+
await import_fs_extra2.default.ensureDir(packagesDestDir);
|
|
224
|
+
const packages = await import_fs_extra2.default.readdir(packagesSourceDir, { withFileTypes: true });
|
|
225
|
+
for (const pkg of packages) {
|
|
226
|
+
if (pkg.isDirectory()) {
|
|
227
|
+
const sourcePath = import_path2.default.join(packagesSourceDir, pkg.name);
|
|
228
|
+
const destPath = import_path2.default.join(packagesDestDir, pkg.name);
|
|
229
|
+
await import_fs_extra2.default.ensureDir(destPath);
|
|
230
|
+
await import_fs_extra2.default.copy(sourcePath, destPath, {
|
|
231
|
+
filter: (src) => {
|
|
232
|
+
const relativePath = import_path2.default.relative(sourcePath, src);
|
|
233
|
+
return !relativePath.includes("node_modules") && !relativePath.includes("dist");
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
await replacePackageNames(destPath, config);
|
|
237
|
+
logger.debug(`Package ${pkg.name} copied`);
|
|
163
238
|
}
|
|
164
|
-
}
|
|
165
|
-
await replacePackageNames(destPath, config);
|
|
166
|
-
logger.debug("Types package copied");
|
|
239
|
+
}
|
|
167
240
|
}
|
|
168
241
|
async function replacePackageNames(directory, config) {
|
|
169
242
|
const { projectName, orgName } = config;
|
|
170
243
|
const filesToUpdate = await findFilesToUpdate(directory);
|
|
171
244
|
for (const filePath of filesToUpdate) {
|
|
172
245
|
try {
|
|
173
|
-
let content = await
|
|
174
|
-
content = content.replace(/\{\{ORG_NAME\}\}/g, orgName).replace(/\{\{PROJECT_NAME\}\}/g, projectName)
|
|
246
|
+
let content = await import_fs_extra2.default.readFile(filePath, "utf8");
|
|
247
|
+
content = content.replace(/\{\{ORG_NAME\}\}/g, orgName).replace(/\{\{PROJECT_NAME\}\}/g, projectName);
|
|
175
248
|
if (filePath.endsWith(".tpl")) {
|
|
176
249
|
const newPath = filePath.replace(/\.tpl$/, "");
|
|
177
|
-
await
|
|
178
|
-
await
|
|
250
|
+
await import_fs_extra2.default.writeFile(newPath, content);
|
|
251
|
+
await import_fs_extra2.default.remove(filePath);
|
|
179
252
|
} else {
|
|
180
|
-
await
|
|
253
|
+
await import_fs_extra2.default.writeFile(filePath, content);
|
|
181
254
|
}
|
|
182
255
|
} catch (error) {
|
|
183
256
|
logger.debug(`Failed to update file ${filePath}: ${error}`);
|
|
@@ -187,13 +260,13 @@ async function replacePackageNames(directory, config) {
|
|
|
187
260
|
async function findFilesToUpdate(directory) {
|
|
188
261
|
const files = [];
|
|
189
262
|
const traverse = async (dir) => {
|
|
190
|
-
const entries = await
|
|
263
|
+
const entries = await import_fs_extra2.default.readdir(dir, { withFileTypes: true });
|
|
191
264
|
for (const entry of entries) {
|
|
192
|
-
const fullPath =
|
|
265
|
+
const fullPath = import_path2.default.join(dir, entry.name);
|
|
193
266
|
if (entry.isDirectory()) {
|
|
194
267
|
await traverse(fullPath);
|
|
195
268
|
} else if (entry.isFile()) {
|
|
196
|
-
const ext =
|
|
269
|
+
const ext = import_path2.default.extname(entry.name);
|
|
197
270
|
const shouldUpdate = [".json", ".ts", ".tsx", ".js", ".jsx", ".md", ".yaml", ".yml", ".env.example", ".tpl"].includes(ext) || entry.name.endsWith(".tpl");
|
|
198
271
|
if (shouldUpdate) {
|
|
199
272
|
files.push(fullPath);
|
|
@@ -220,7 +293,7 @@ async function copyBuiltInTemplates(config) {
|
|
|
220
293
|
}
|
|
221
294
|
async function createMinimalBackend(config) {
|
|
222
295
|
const dir = "apps/backend";
|
|
223
|
-
await
|
|
296
|
+
await import_fs_extra2.default.ensureDir(dir);
|
|
224
297
|
const packageJson = {
|
|
225
298
|
name: `${config.orgName}/backend`,
|
|
226
299
|
version: "1.0.0",
|
|
@@ -245,11 +318,11 @@ async function createMinimalBackend(config) {
|
|
|
245
318
|
"typescript": "^5.3.0"
|
|
246
319
|
}
|
|
247
320
|
};
|
|
248
|
-
await
|
|
321
|
+
await import_fs_extra2.default.writeJson(import_path2.default.join(dir, "package.json"), packageJson, { spaces: 2 });
|
|
249
322
|
}
|
|
250
323
|
async function createMinimalAdmin(config) {
|
|
251
324
|
const dir = "apps/admin";
|
|
252
|
-
await
|
|
325
|
+
await import_fs_extra2.default.ensureDir(dir);
|
|
253
326
|
const packageJson = {
|
|
254
327
|
name: `${config.orgName}/admin`,
|
|
255
328
|
version: "1.0.0",
|
|
@@ -273,11 +346,11 @@ async function createMinimalAdmin(config) {
|
|
|
273
346
|
"typescript": "^5.7.3"
|
|
274
347
|
}
|
|
275
348
|
};
|
|
276
|
-
await
|
|
349
|
+
await import_fs_extra2.default.writeJson(import_path2.default.join(dir, "package.json"), packageJson, { spaces: 2 });
|
|
277
350
|
}
|
|
278
351
|
async function createMinimalMobile(config) {
|
|
279
352
|
const dir = "apps/mobile";
|
|
280
|
-
await
|
|
353
|
+
await import_fs_extra2.default.ensureDir(dir);
|
|
281
354
|
const packageJson = {
|
|
282
355
|
name: `${config.orgName}/mobile`,
|
|
283
356
|
version: "1.0.0",
|
|
@@ -302,13 +375,13 @@ async function createMinimalMobile(config) {
|
|
|
302
375
|
"typescript": "^5.3.3"
|
|
303
376
|
}
|
|
304
377
|
};
|
|
305
|
-
await
|
|
378
|
+
await import_fs_extra2.default.writeJson(import_path2.default.join(dir, "package.json"), packageJson, { spaces: 2 });
|
|
306
379
|
}
|
|
307
380
|
async function createMinimalTypes(config) {
|
|
308
381
|
const dir = "packages/types";
|
|
309
|
-
await
|
|
382
|
+
await import_fs_extra2.default.ensureDir(dir);
|
|
310
383
|
const packageJson = {
|
|
311
|
-
name:
|
|
384
|
+
name: `@${config.orgName}/types`,
|
|
312
385
|
version: "1.0.0",
|
|
313
386
|
description: "Shared type definitions",
|
|
314
387
|
main: "./dist/index.js",
|
|
@@ -323,7 +396,7 @@ async function createMinimalTypes(config) {
|
|
|
323
396
|
"typescript": "^5.3.3"
|
|
324
397
|
}
|
|
325
398
|
};
|
|
326
|
-
await
|
|
399
|
+
await import_fs_extra2.default.writeJson(import_path2.default.join(dir, "package.json"), packageJson, { spaces: 2 });
|
|
327
400
|
}
|
|
328
401
|
|
|
329
402
|
// src/utils/template.ts
|
|
@@ -366,12 +439,12 @@ async function createRootFiles(config) {
|
|
|
366
439
|
pnpm: ">=8.0.0"
|
|
367
440
|
}
|
|
368
441
|
};
|
|
369
|
-
await
|
|
442
|
+
await import_fs_extra3.default.writeJson("package.json", packageJson, { spaces: 2 });
|
|
370
443
|
const workspaceConfig = `packages:
|
|
371
444
|
- 'apps/*'
|
|
372
445
|
- 'packages/*'
|
|
373
446
|
`;
|
|
374
|
-
await
|
|
447
|
+
await import_fs_extra3.default.writeFile("pnpm-workspace.yaml", workspaceConfig);
|
|
375
448
|
const turboConfig = {
|
|
376
449
|
"$schema": "https://turbo.build/schema.json",
|
|
377
450
|
pipeline: {
|
|
@@ -395,7 +468,7 @@ async function createRootFiles(config) {
|
|
|
395
468
|
}
|
|
396
469
|
}
|
|
397
470
|
};
|
|
398
|
-
await
|
|
471
|
+
await import_fs_extra3.default.writeJson("turbo.json", turboConfig, { spaces: 2 });
|
|
399
472
|
const gitignore = `# Dependencies
|
|
400
473
|
node_modules/
|
|
401
474
|
.pnpm-store/
|
|
@@ -433,11 +506,11 @@ coverage/
|
|
|
433
506
|
# Misc
|
|
434
507
|
*.tsbuildinfo
|
|
435
508
|
`;
|
|
436
|
-
await
|
|
509
|
+
await import_fs_extra3.default.writeFile(".gitignore", gitignore);
|
|
437
510
|
const npmrc = `auto-install-peers=true
|
|
438
511
|
strict-peer-dependencies=false
|
|
439
512
|
`;
|
|
440
|
-
await
|
|
513
|
+
await import_fs_extra3.default.writeFile(".npmrc", npmrc);
|
|
441
514
|
const dockerCompose = `version: '3.8'
|
|
442
515
|
|
|
443
516
|
services:
|
|
@@ -469,9 +542,9 @@ volumes:
|
|
|
469
542
|
mysql_data:
|
|
470
543
|
redis_data:
|
|
471
544
|
`;
|
|
472
|
-
await
|
|
545
|
+
await import_fs_extra3.default.writeFile("docker-compose.yml", dockerCompose);
|
|
473
546
|
const readme = await generateReadme(config);
|
|
474
|
-
await
|
|
547
|
+
await import_fs_extra3.default.writeFile("README.md", readme);
|
|
475
548
|
}
|
|
476
549
|
async function generateReadme(config) {
|
|
477
550
|
const { projectName, orgName, template } = config;
|
|
@@ -556,12 +629,12 @@ Generated with \`create-svton-app\`
|
|
|
556
629
|
}
|
|
557
630
|
|
|
558
631
|
// src/utils/install.ts
|
|
559
|
-
var
|
|
632
|
+
var import_child_process2 = require("child_process");
|
|
560
633
|
async function installDependencies(packageManager) {
|
|
561
634
|
try {
|
|
562
635
|
const command = getInstallCommand(packageManager);
|
|
563
636
|
logger.debug(`Running: ${command}`);
|
|
564
|
-
(0,
|
|
637
|
+
(0, import_child_process2.execSync)(command, {
|
|
565
638
|
stdio: "inherit",
|
|
566
639
|
cwd: process.cwd()
|
|
567
640
|
});
|
|
@@ -583,18 +656,18 @@ function getInstallCommand(packageManager) {
|
|
|
583
656
|
}
|
|
584
657
|
|
|
585
658
|
// src/utils/git.ts
|
|
586
|
-
var
|
|
659
|
+
var import_child_process3 = require("child_process");
|
|
587
660
|
async function initGit(projectName) {
|
|
588
661
|
try {
|
|
589
662
|
try {
|
|
590
|
-
(0,
|
|
663
|
+
(0, import_child_process3.execSync)("git status", { stdio: "ignore" });
|
|
591
664
|
logger.debug("Git repository already exists, skipping initialization");
|
|
592
665
|
return;
|
|
593
666
|
} catch {
|
|
594
667
|
}
|
|
595
|
-
(0,
|
|
596
|
-
(0,
|
|
597
|
-
(0,
|
|
668
|
+
(0, import_child_process3.execSync)("git init", { stdio: "ignore" });
|
|
669
|
+
(0, import_child_process3.execSync)("git add .", { stdio: "ignore" });
|
|
670
|
+
(0, import_child_process3.execSync)(`git commit -m "feat: initialize ${projectName} project"`, {
|
|
598
671
|
stdio: "ignore"
|
|
599
672
|
});
|
|
600
673
|
logger.debug("Git repository initialized successfully");
|
|
@@ -615,8 +688,8 @@ async function createProject(projectName, options = {}) {
|
|
|
615
688
|
}
|
|
616
689
|
process.exit(1);
|
|
617
690
|
}
|
|
618
|
-
const projectPath =
|
|
619
|
-
if (await
|
|
691
|
+
const projectPath = import_path3.default.resolve(process.cwd(), projectName);
|
|
692
|
+
if (await import_fs_extra4.default.pathExists(projectPath)) {
|
|
620
693
|
logger.error(`Directory ${projectName} already exists!`);
|
|
621
694
|
process.exit(1);
|
|
622
695
|
}
|
|
@@ -734,7 +807,7 @@ async function createProject(projectName, options = {}) {
|
|
|
734
807
|
async function createProjectFromTemplate(config) {
|
|
735
808
|
const spinner = (0, import_ora.default)("Creating project...").start();
|
|
736
809
|
try {
|
|
737
|
-
await
|
|
810
|
+
await import_fs_extra4.default.ensureDir(config.projectPath);
|
|
738
811
|
process.chdir(config.projectPath);
|
|
739
812
|
spinner.text = "Generating project files...";
|
|
740
813
|
await generateFromTemplate(config);
|
|
@@ -754,7 +827,7 @@ async function createProjectFromTemplate(config) {
|
|
|
754
827
|
}
|
|
755
828
|
|
|
756
829
|
// package.json
|
|
757
|
-
var version = "1.0.
|
|
830
|
+
var version = "1.0.7";
|
|
758
831
|
|
|
759
832
|
// src/index.ts
|
|
760
833
|
async function cli() {
|