create-turbo-kit 1.0.1 → 1.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.
package/src/cli.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { intro, outro, text, select, isCancel, cancel, confirm } from '@clack/prompts';
1
+ import { intro, outro, text, select, isCancel, cancel, confirm, multiselect } from '@clack/prompts';
2
2
  import { Command } from 'commander';
3
3
  import color from 'picocolors';
4
4
  import fs from 'fs-extra';
5
5
  import path from 'path';
6
- import { replaceScope, setupEnv } from './helpers/transform.js';
7
- import { installDependencies } from './helpers/install.js';
6
+ import { replaceScope, setupEnv, getDockerContainers, configureDockerCompose, deleteDockerCompose } from './helpers/transform.js';
7
+ import { installDependencies, initializeGit } from './helpers/install.js';
8
8
  import { type PackageManager } from './utils/package-manager.js';
9
9
  import { scaffoldProject } from './helpers/scaffold.js';
10
10
 
@@ -30,6 +30,11 @@ async function main() {
30
30
  validate: (value) => {
31
31
  if (!value) return 'Please enter a name.';
32
32
  if (/[^a-zA-Z0-9-_]/.test(value)) return 'Project name can only contain letters, numbers, dashes and underscores.';
33
+ const projectDir = path.resolve(process.cwd(), value);
34
+ if (fs.pathExistsSync(projectDir)) {
35
+ return 'Project name already taken.';
36
+ }
37
+ return undefined;
33
38
  },
34
39
  });
35
40
 
@@ -108,14 +113,65 @@ async function main() {
108
113
  packageManager: packageManager as PackageManager,
109
114
  });
110
115
 
116
+ const wantsDocker = await confirm({
117
+ message: 'Do you want to set up a local Docker Compose dev environment?',
118
+ initialValue: true,
119
+ });
120
+
121
+ if (isCancel(wantsDocker)) {
122
+ cancel('Operation cancelled.');
123
+ process.exit(0);
124
+ }
125
+
126
+ if (wantsDocker) {
127
+ const dockerContainers = getDockerContainers();
128
+ const containers = await multiselect({
129
+ message: 'Which containers do you want to include?',
130
+ options: dockerContainers,
131
+ initialValues: dockerContainers.map((container) => container.value),
132
+ required: false,
133
+ });
134
+
135
+ if (isCancel(containers)) {
136
+ cancel('Operation cancelled.');
137
+ process.exit(0);
138
+ }
139
+
140
+ if (Array.isArray(containers) && containers.length > 0) {
141
+ await configureDockerCompose(projectDir, containers as string[]);
142
+ } else {
143
+ await deleteDockerCompose(projectDir);
144
+ }
145
+ } else {
146
+ await deleteDockerCompose(projectDir);
147
+ }
148
+
149
+ const shouldInstall = await confirm({
150
+ message: 'Do you want to install dependencies now?',
151
+ initialValue: true,
152
+ });
153
+
154
+ if (isCancel(shouldInstall)) {
155
+ cancel('Operation cancelled.');
156
+ process.exit(0);
157
+ }
158
+
111
159
  await replaceScope(projectDir, scope as string);
112
160
  await setupEnv(projectDir);
113
- await installDependencies(projectDir, packageManager as PackageManager);
161
+
162
+ if (shouldInstall) {
163
+ await installDependencies(projectDir, packageManager as PackageManager);
164
+ }
165
+
166
+ await initializeGit(projectDir);
114
167
 
115
168
  outro(color.green('Project initialized successfully!'));
116
169
 
117
170
  console.log(`To get started:`);
118
171
  console.log(color.cyan(` cd ${projectName}`));
172
+ if (!shouldInstall) {
173
+ console.log(color.cyan(` ${packageManager} install`));
174
+ }
119
175
  console.log(color.cyan(` ${packageManager} run dev`));
120
176
 
121
177
  console.log();
@@ -21,3 +21,25 @@ export async function installDependencies(projectDir: string, packageManager: Pa
21
21
  }
22
22
  }
23
23
 
24
+ export async function initializeGit(projectDir: string) {
25
+ const s = spinner();
26
+ s.start('Initializing git repository...');
27
+
28
+ try {
29
+ await execa('git', ['init'], {
30
+ cwd: projectDir,
31
+ });
32
+ await execa('git', ['add', '.'], {
33
+ cwd: projectDir,
34
+ });
35
+ await execa('git', ['commit', '-m', 'Initial commit'], {
36
+ cwd: projectDir,
37
+ });
38
+
39
+ s.stop('Initialized git repository');
40
+ } catch (error) {
41
+ s.stop('Failed to initialize git repository');
42
+ throw error;
43
+ }
44
+ }
45
+
@@ -24,6 +24,7 @@ export async function scaffoldProject({ projectName, packageManager }: ScaffoldO
24
24
  '--package-manager',
25
25
  packageManager,
26
26
  '--skip-install',
27
+ '--no-git',
27
28
  projectName
28
29
  ]);
29
30
 
@@ -4,6 +4,26 @@ import path from 'path';
4
4
  import { spinner } from '@clack/prompts';
5
5
  import color from 'picocolors';
6
6
 
7
+ const DOCKER_CONTAINERS = {
8
+ postgres: {
9
+ label: 'PostgreSQL 16 (Database)',
10
+ services: ['postgres'],
11
+ volumes: ['postgres_data'],
12
+ },
13
+ mailpit: {
14
+ label: 'Mailpit (Email testing)',
15
+ services: ['mailpit'],
16
+ volumes: [],
17
+ },
18
+ minio: {
19
+ label: 'MinIO (S3-compatible storage)',
20
+ services: ['minio', 'minio-create-bucket'],
21
+ volumes: ['minio_data'],
22
+ },
23
+ } as const;
24
+
25
+ export type DockerContainer = keyof typeof DOCKER_CONTAINERS;
26
+
7
27
  export async function replaceScope(projectDir: string, newScope: string) {
8
28
  const s = spinner();
9
29
  s.start(`Replacing scope with ${color.cyan(newScope)}...`);
@@ -54,3 +74,63 @@ export async function setupEnv(projectDir: string) {
54
74
  }
55
75
  }
56
76
 
77
+ export function getDockerContainers() {
78
+ return Object.entries(DOCKER_CONTAINERS).map(([value, config]) => ({
79
+ value,
80
+ label: config.label,
81
+ }));
82
+ }
83
+
84
+ export async function deleteDockerCompose(projectDir: string) {
85
+ const s = spinner();
86
+ s.start('Removing Docker Compose setup...');
87
+
88
+ try {
89
+ const dockerComposePath = path.join(projectDir, 'docker-compose.yml');
90
+ if (await fs.pathExists(dockerComposePath)) {
91
+ await fs.remove(dockerComposePath);
92
+ }
93
+ s.stop('Removed Docker Compose setup');
94
+ } catch (error) {
95
+ s.stop('Failed to remove Docker Compose setup');
96
+ throw error;
97
+ }
98
+ }
99
+
100
+ export async function configureDockerCompose(projectDir: string, selectedContainers: string[]) {
101
+ const s = spinner();
102
+ s.start('Configuring Docker Compose...');
103
+
104
+ try {
105
+ const dockerComposePath = path.join(projectDir, 'docker-compose.yml');
106
+
107
+ if (!(await fs.pathExists(dockerComposePath))) {
108
+ s.stop('Docker Compose file not found');
109
+ return;
110
+ }
111
+
112
+ let content = await fs.readFile(dockerComposePath, 'utf8');
113
+
114
+ const allContainers = Object.keys(DOCKER_CONTAINERS) as DockerContainer[];
115
+ const containersToRemove = allContainers.filter(c => !selectedContainers.includes(c));
116
+
117
+ for (const container of containersToRemove) {
118
+ const containerRegex = new RegExp(
119
+ ` # -- ${container} --\\n[\\s\\S]*? # // ${container} //\\n`,
120
+ 'g'
121
+ );
122
+ content = content.replace(containerRegex, '');
123
+ }
124
+
125
+ content = content.replace(/ # -- \w+ --\n/g, '');
126
+ content = content.replace(/ # \/\/ \w+ \/\/\n/g, '');
127
+
128
+ await fs.writeFile(dockerComposePath, content);
129
+
130
+ s.stop(`Configured Docker Compose with ${color.cyan(selectedContainers.length)} container(s)`);
131
+ } catch (error) {
132
+ s.stop('Failed to configure Docker Compose');
133
+ throw error;
134
+ }
135
+ }
136
+
package/tsup.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from 'tsup';
2
+
3
+ export default defineConfig({
4
+ entry: ['src/cli.ts'],
5
+ format: ['esm'],
6
+ dts: true,
7
+ sourcemap: true,
8
+ clean: true,
9
+ shims: false,
10
+ });
package/dist/cli.cjs DELETED
@@ -1,256 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
-
25
- // src/cli.ts
26
- var import_prompts4 = require("@clack/prompts");
27
- var import_commander = require("commander");
28
- var import_picocolors4 = __toESM(require("picocolors"), 1);
29
- var import_fs_extra2 = __toESM(require("fs-extra"), 1);
30
- var import_path2 = __toESM(require("path"), 1);
31
-
32
- // src/helpers/transform.ts
33
- var import_fast_glob = __toESM(require("fast-glob"), 1);
34
- var import_fs_extra = __toESM(require("fs-extra"), 1);
35
- var import_path = __toESM(require("path"), 1);
36
- var import_prompts = require("@clack/prompts");
37
- var import_picocolors = __toESM(require("picocolors"), 1);
38
- async function replaceScope(projectDir, newScope) {
39
- const s = (0, import_prompts.spinner)();
40
- s.start(`Replacing scope with ${import_picocolors.default.cyan(newScope)}...`);
41
- try {
42
- const files = await (0, import_fast_glob.default)("**/*", {
43
- cwd: projectDir,
44
- ignore: [
45
- "**/.git/**",
46
- "**/node_modules/**",
47
- "**/.turbo/**",
48
- "**/dist/**",
49
- "**/.next/**",
50
- "**/pnpm-lock.yaml",
51
- "**/yarn.lock",
52
- "**/package-lock.json",
53
- "**/bun.lockb"
54
- ],
55
- absolute: true
56
- });
57
- await Promise.all(
58
- files.map(async (file) => {
59
- try {
60
- const content = await import_fs_extra.default.readFile(file, "utf8");
61
- if (content.includes("@acme")) {
62
- const newContent = content.replace(/@acme/g, newScope);
63
- await import_fs_extra.default.writeFile(file, newContent);
64
- }
65
- } catch (e) {
66
- }
67
- })
68
- );
69
- s.stop(`Replaced scope with ${import_picocolors.default.cyan(newScope)}`);
70
- } catch (error) {
71
- s.stop("Failed to replace scope");
72
- throw error;
73
- }
74
- }
75
- async function setupEnv(projectDir) {
76
- const envExample = import_path.default.join(projectDir, ".env.example");
77
- const envDest = import_path.default.join(projectDir, ".env");
78
- if (await import_fs_extra.default.pathExists(envExample)) {
79
- await import_fs_extra.default.copy(envExample, envDest);
80
- }
81
- }
82
-
83
- // src/helpers/install.ts
84
- var import_execa = require("execa");
85
- var import_prompts2 = require("@clack/prompts");
86
-
87
- // src/utils/package-manager.ts
88
- function getRunner(pm) {
89
- switch (pm) {
90
- case "npm":
91
- return "npx";
92
- case "pnpm":
93
- return "pnpm dlx";
94
- case "yarn":
95
- return "yarn dlx";
96
- case "bun":
97
- return "bunx";
98
- default:
99
- return "npx";
100
- }
101
- }
102
- function getInstallCommand(pm) {
103
- switch (pm) {
104
- case "npm":
105
- return "npm install";
106
- case "pnpm":
107
- return "pnpm install";
108
- case "yarn":
109
- return "yarn install";
110
- case "bun":
111
- return "bun install";
112
- default:
113
- return "npm install";
114
- }
115
- }
116
-
117
- // src/helpers/install.ts
118
- var import_picocolors2 = __toESM(require("picocolors"), 1);
119
- async function installDependencies(projectDir, packageManager) {
120
- const s = (0, import_prompts2.spinner)();
121
- s.start(`Installing dependencies with ${import_picocolors2.default.cyan(packageManager)}...`);
122
- const installCmd = getInstallCommand(packageManager);
123
- const [command = "npm", ...args] = installCmd.split(" ");
124
- try {
125
- await (0, import_execa.execa)(command, args, {
126
- cwd: projectDir
127
- });
128
- s.stop(`Installed dependencies`);
129
- } catch (error) {
130
- s.stop(`Failed to install dependencies`);
131
- throw error;
132
- }
133
- }
134
-
135
- // src/helpers/scaffold.ts
136
- var import_execa2 = require("execa");
137
- var import_prompts3 = require("@clack/prompts");
138
- var import_picocolors3 = __toESM(require("picocolors"), 1);
139
- async function scaffoldProject({ projectName, packageManager }) {
140
- const s = (0, import_prompts3.spinner)();
141
- s.start(`Scaffolding project in ${import_picocolors3.default.cyan(projectName)}...`);
142
- const runner = getRunner(packageManager);
143
- const [command = "npx", ...args] = runner.split(" ");
144
- try {
145
- await (0, import_execa2.execa)(command, [
146
- ...args,
147
- "create-turbo@latest",
148
- "-e",
149
- "https://github.com/Badbird5907/turbo-kit",
150
- "--package-manager",
151
- packageManager,
152
- "--skip-install",
153
- projectName
154
- ]);
155
- s.stop(`Scaffolded project in ${import_picocolors3.default.cyan(projectName)}`);
156
- } catch (error) {
157
- s.stop(`Failed to scaffold project`);
158
- throw error;
159
- }
160
- }
161
-
162
- // src/cli.ts
163
- async function main() {
164
- const program = new import_commander.Command();
165
- program.name("create-turbo-kit").description("Initialize a custom turborepo template").argument("[project-name]", "Name of the project directory").parse(process.argv);
166
- const args = program.args;
167
- let projectName = args[0];
168
- console.log();
169
- (0, import_prompts4.intro)(import_picocolors4.default.bgCyan(import_picocolors4.default.black(" Create Turbo Kit ")));
170
- if (!projectName) {
171
- const pName = await (0, import_prompts4.text)({
172
- message: "What is your project named?",
173
- placeholder: "my-turbo-app",
174
- validate: (value) => {
175
- if (!value) return "Please enter a name.";
176
- if (/[^a-zA-Z0-9-_]/.test(value)) return "Project name can only contain letters, numbers, dashes and underscores.";
177
- }
178
- });
179
- if ((0, import_prompts4.isCancel)(pName)) {
180
- (0, import_prompts4.cancel)("Operation cancelled.");
181
- process.exit(0);
182
- }
183
- projectName = pName;
184
- }
185
- const projectDir = import_path2.default.resolve(process.cwd(), projectName);
186
- if (await import_fs_extra2.default.pathExists(projectDir)) {
187
- const shouldOverwrite = await (0, import_prompts4.confirm)({
188
- message: `Directory ${projectName} already exists. Do you want to overwrite it?`,
189
- initialValue: false
190
- });
191
- if ((0, import_prompts4.isCancel)(shouldOverwrite) || !shouldOverwrite) {
192
- (0, import_prompts4.cancel)("Operation cancelled.");
193
- process.exit(0);
194
- }
195
- await import_fs_extra2.default.remove(projectDir);
196
- }
197
- const packageManager = await (0, import_prompts4.select)({
198
- message: "Which package manager do you want to use?",
199
- options: [
200
- { value: "pnpm", label: "pnpm" },
201
- { value: "npm", label: "npm" },
202
- { value: "yarn", label: "yarn" },
203
- { value: "bun", label: "bun" }
204
- ]
205
- });
206
- if ((0, import_prompts4.isCancel)(packageManager)) {
207
- (0, import_prompts4.cancel)("Operation cancelled.");
208
- process.exit(0);
209
- }
210
- const getScope = async () => {
211
- const scope2 = await (0, import_prompts4.text)({
212
- message: "What is your package scope?",
213
- placeholder: "@my-org",
214
- validate: (value) => {
215
- if (!value) return "Please enter a scope.";
216
- }
217
- });
218
- if ((0, import_prompts4.isCancel)(scope2)) {
219
- (0, import_prompts4.cancel)("Operation cancelled.");
220
- process.exit(0);
221
- }
222
- const check = ["@", "~", "$", "#", "!"];
223
- if (!check.includes(scope2[0])) {
224
- const importStatement = `${import_picocolors4.default.magenta("import")} ${import_picocolors4.default.yellow("{")} ${import_picocolors4.default.cyan("example")} ${import_picocolors4.default.yellow("}")} ${import_picocolors4.default.magenta("from")} ${import_picocolors4.default.cyan(`"${scope2}/example"`)}`;
225
- const confirmScope = await (0, import_prompts4.confirm)({
226
- message: `Is ${import_picocolors4.default.cyan(scope2)} the correct scope?
227
- Your import statements will look like this: ${importStatement}`,
228
- initialValue: true
229
- });
230
- if ((0, import_prompts4.isCancel)(confirmScope) || !confirmScope) {
231
- return await getScope();
232
- }
233
- }
234
- return scope2;
235
- };
236
- const scope = await getScope();
237
- try {
238
- await scaffoldProject({
239
- projectName,
240
- packageManager
241
- });
242
- await replaceScope(projectDir, scope);
243
- await setupEnv(projectDir);
244
- await installDependencies(projectDir, packageManager);
245
- (0, import_prompts4.outro)(import_picocolors4.default.green("Project initialized successfully!"));
246
- console.log(`To get started:`);
247
- console.log(import_picocolors4.default.cyan(` cd ${projectName}`));
248
- console.log(import_picocolors4.default.cyan(` ${packageManager} run dev`));
249
- console.log();
250
- console.log(import_picocolors4.default.greenBright("Happy Hacking!"));
251
- } catch (error) {
252
- console.error(import_picocolors4.default.red("An error occurred:"), error);
253
- process.exit(1);
254
- }
255
- }
256
- main().catch(console.error);
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/helpers/install.ts
31
- var install_exports = {};
32
- __export(install_exports, {
33
- installDependencies: () => installDependencies
34
- });
35
- module.exports = __toCommonJS(install_exports);
36
- var import_execa = require("execa");
37
- var import_prompts = require("@clack/prompts");
38
-
39
- // src/utils/package-manager.ts
40
- function getInstallCommand(pm) {
41
- switch (pm) {
42
- case "npm":
43
- return "npm install";
44
- case "pnpm":
45
- return "pnpm install";
46
- case "yarn":
47
- return "yarn install";
48
- case "bun":
49
- return "bun install";
50
- default:
51
- return "npm install";
52
- }
53
- }
54
-
55
- // src/helpers/install.ts
56
- var import_picocolors = __toESM(require("picocolors"), 1);
57
- async function installDependencies(projectDir, packageManager) {
58
- const s = (0, import_prompts.spinner)();
59
- s.start(`Installing dependencies with ${import_picocolors.default.cyan(packageManager)}...`);
60
- const installCmd = getInstallCommand(packageManager);
61
- const [command = "npm", ...args] = installCmd.split(" ");
62
- try {
63
- await (0, import_execa.execa)(command, args, {
64
- cwd: projectDir
65
- });
66
- s.stop(`Installed dependencies`);
67
- } catch (error) {
68
- s.stop(`Failed to install dependencies`);
69
- throw error;
70
- }
71
- }
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- installDependencies
75
- });
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/helpers/scaffold.ts
31
- var scaffold_exports = {};
32
- __export(scaffold_exports, {
33
- scaffoldProject: () => scaffoldProject
34
- });
35
- module.exports = __toCommonJS(scaffold_exports);
36
- var import_execa = require("execa");
37
- var import_prompts = require("@clack/prompts");
38
-
39
- // src/utils/package-manager.ts
40
- function getRunner(pm) {
41
- switch (pm) {
42
- case "npm":
43
- return "npx";
44
- case "pnpm":
45
- return "pnpm dlx";
46
- case "yarn":
47
- return "yarn dlx";
48
- case "bun":
49
- return "bunx";
50
- default:
51
- return "npx";
52
- }
53
- }
54
-
55
- // src/helpers/scaffold.ts
56
- var import_picocolors = __toESM(require("picocolors"), 1);
57
- async function scaffoldProject({ projectName, packageManager }) {
58
- const s = (0, import_prompts.spinner)();
59
- s.start(`Scaffolding project in ${import_picocolors.default.cyan(projectName)}...`);
60
- const runner = getRunner(packageManager);
61
- const [command = "npx", ...args] = runner.split(" ");
62
- try {
63
- await (0, import_execa.execa)(command, [
64
- ...args,
65
- "create-turbo@latest",
66
- "-e",
67
- "https://github.com/Badbird5907/turbo-kit",
68
- "--package-manager",
69
- packageManager,
70
- "--skip-install",
71
- projectName
72
- ]);
73
- s.stop(`Scaffolded project in ${import_picocolors.default.cyan(projectName)}`);
74
- } catch (error) {
75
- s.stop(`Failed to scaffold project`);
76
- throw error;
77
- }
78
- }
79
- // Annotate the CommonJS export names for ESM import in node:
80
- 0 && (module.exports = {
81
- scaffoldProject
82
- });