create-turbo-kit 1.0.1 → 1.0.2
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/chunk-EYEU3RGM.js +35 -0
- package/dist/chunk-EYEU3RGM.js.map +1 -0
- package/dist/chunk-G5KXW3XA.js +28 -0
- package/dist/chunk-G5KXW3XA.js.map +1 -0
- package/dist/chunk-GB72MU2M.js +56 -0
- package/dist/chunk-GB72MU2M.js.map +1 -0
- package/dist/chunk-MBDFMIAE.js +35 -0
- package/dist/chunk-MBDFMIAE.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +113 -0
- package/dist/cli.js.map +1 -0
- package/dist/helpers/install.d.ts +5 -0
- package/dist/helpers/install.js +8 -0
- package/dist/helpers/install.js.map +1 -0
- package/dist/helpers/scaffold.d.ts +9 -0
- package/dist/helpers/scaffold.js +8 -0
- package/dist/helpers/scaffold.js.map +1 -0
- package/dist/helpers/transform.d.ts +4 -0
- package/dist/helpers/transform.js +9 -0
- package/dist/helpers/transform.js.map +1 -0
- package/dist/utils/package-manager.d.ts +5 -0
- package/dist/utils/package-manager.js +9 -0
- package/dist/utils/package-manager.js.map +1 -0
- package/package.json +5 -2
- package/tsup.config.ts +10 -0
- package/dist/cli.cjs +0 -256
- package/dist/helpers/install.cjs +0 -75
- package/dist/helpers/scaffold.cjs +0 -82
- package/dist/helpers/transform.cjs +0 -90
- package/dist/utils/package-manager.cjs +0 -59
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/utils/package-manager.ts
|
|
2
|
+
function getRunner(pm) {
|
|
3
|
+
switch (pm) {
|
|
4
|
+
case "npm":
|
|
5
|
+
return "npx";
|
|
6
|
+
case "pnpm":
|
|
7
|
+
return "pnpm dlx";
|
|
8
|
+
case "yarn":
|
|
9
|
+
return "yarn dlx";
|
|
10
|
+
case "bun":
|
|
11
|
+
return "bunx";
|
|
12
|
+
default:
|
|
13
|
+
return "npx";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function getInstallCommand(pm) {
|
|
17
|
+
switch (pm) {
|
|
18
|
+
case "npm":
|
|
19
|
+
return "npm install";
|
|
20
|
+
case "pnpm":
|
|
21
|
+
return "pnpm install";
|
|
22
|
+
case "yarn":
|
|
23
|
+
return "yarn install";
|
|
24
|
+
case "bun":
|
|
25
|
+
return "bun install";
|
|
26
|
+
default:
|
|
27
|
+
return "npm install";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
getRunner,
|
|
33
|
+
getInstallCommand
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-EYEU3RGM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/package-manager.ts"],"sourcesContent":["export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\r\n\r\nexport function getRunner(pm: PackageManager): string {\r\n switch (pm) {\r\n case 'npm':\r\n return 'npx';\r\n case 'pnpm':\r\n return 'pnpm dlx';\r\n case 'yarn':\r\n return 'yarn dlx';\r\n case 'bun':\r\n return 'bunx';\r\n default:\r\n return 'npx';\r\n }\r\n}\r\n\r\nexport function getInstallCommand(pm: PackageManager): string {\r\n switch (pm) {\r\n case 'npm':\r\n return 'npm install';\r\n case 'pnpm':\r\n return 'pnpm install';\r\n case 'yarn':\r\n return 'yarn install';\r\n case 'bun':\r\n return 'bun install';\r\n default:\r\n return 'npm install';\r\n }\r\n}\r\n\r\n"],"mappings":";AAEO,SAAS,UAAU,IAA4B;AACpD,UAAQ,IAAI;AAAA,IACV,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEO,SAAS,kBAAkB,IAA4B;AAC5D,UAAQ,IAAI;AAAA,IACV,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInstallCommand
|
|
3
|
+
} from "./chunk-EYEU3RGM.js";
|
|
4
|
+
|
|
5
|
+
// src/helpers/install.ts
|
|
6
|
+
import { execa } from "execa";
|
|
7
|
+
import { spinner } from "@clack/prompts";
|
|
8
|
+
import color from "picocolors";
|
|
9
|
+
async function installDependencies(projectDir, packageManager) {
|
|
10
|
+
const s = spinner();
|
|
11
|
+
s.start(`Installing dependencies with ${color.cyan(packageManager)}...`);
|
|
12
|
+
const installCmd = getInstallCommand(packageManager);
|
|
13
|
+
const [command = "npm", ...args] = installCmd.split(" ");
|
|
14
|
+
try {
|
|
15
|
+
await execa(command, args, {
|
|
16
|
+
cwd: projectDir
|
|
17
|
+
});
|
|
18
|
+
s.stop(`Installed dependencies`);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
s.stop(`Failed to install dependencies`);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
installDependencies
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=chunk-G5KXW3XA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/install.ts"],"sourcesContent":["import { execa } from 'execa';\r\nimport { spinner } from '@clack/prompts';\r\nimport { type PackageManager, getInstallCommand } from '../utils/package-manager.js';\r\nimport color from 'picocolors';\r\n\r\nexport async function installDependencies(projectDir: string, packageManager: PackageManager) {\r\n const s = spinner();\r\n s.start(`Installing dependencies with ${color.cyan(packageManager)}...`);\r\n\r\n const installCmd = getInstallCommand(packageManager);\r\n const [command = \"npm\", ...args] = installCmd.split(' ');\r\n\r\n try {\r\n await execa(command, args, {\r\n cwd: projectDir,\r\n });\r\n s.stop(`Installed dependencies`);\r\n } catch (error) {\r\n s.stop(`Failed to install dependencies`);\r\n throw error;\r\n }\r\n}\r\n\r\n"],"mappings":";;;;;AAAA,SAAS,aAAa;AACtB,SAAS,eAAe;AAExB,OAAO,WAAW;AAElB,eAAsB,oBAAoB,YAAoB,gBAAgC;AAC5F,QAAM,IAAI,QAAQ;AAClB,IAAE,MAAM,gCAAgC,MAAM,KAAK,cAAc,CAAC,KAAK;AAEvE,QAAM,aAAa,kBAAkB,cAAc;AACnD,QAAM,CAAC,UAAU,OAAO,GAAG,IAAI,IAAI,WAAW,MAAM,GAAG;AAEvD,MAAI;AACF,UAAM,MAAM,SAAS,MAAM;AAAA,MACzB,KAAK;AAAA,IACP,CAAC;AACD,MAAE,KAAK,wBAAwB;AAAA,EACjC,SAAS,OAAO;AACd,MAAE,KAAK,gCAAgC;AACvC,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/helpers/transform.ts
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { spinner } from "@clack/prompts";
|
|
6
|
+
import color from "picocolors";
|
|
7
|
+
async function replaceScope(projectDir, newScope) {
|
|
8
|
+
const s = spinner();
|
|
9
|
+
s.start(`Replacing scope with ${color.cyan(newScope)}...`);
|
|
10
|
+
try {
|
|
11
|
+
const files = await fg("**/*", {
|
|
12
|
+
cwd: projectDir,
|
|
13
|
+
ignore: [
|
|
14
|
+
"**/.git/**",
|
|
15
|
+
"**/node_modules/**",
|
|
16
|
+
"**/.turbo/**",
|
|
17
|
+
"**/dist/**",
|
|
18
|
+
"**/.next/**",
|
|
19
|
+
"**/pnpm-lock.yaml",
|
|
20
|
+
"**/yarn.lock",
|
|
21
|
+
"**/package-lock.json",
|
|
22
|
+
"**/bun.lockb"
|
|
23
|
+
],
|
|
24
|
+
absolute: true
|
|
25
|
+
});
|
|
26
|
+
await Promise.all(
|
|
27
|
+
files.map(async (file) => {
|
|
28
|
+
try {
|
|
29
|
+
const content = await fs.readFile(file, "utf8");
|
|
30
|
+
if (content.includes("@acme")) {
|
|
31
|
+
const newContent = content.replace(/@acme/g, newScope);
|
|
32
|
+
await fs.writeFile(file, newContent);
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
s.stop(`Replaced scope with ${color.cyan(newScope)}`);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
s.stop("Failed to replace scope");
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function setupEnv(projectDir) {
|
|
45
|
+
const envExample = path.join(projectDir, ".env.example");
|
|
46
|
+
const envDest = path.join(projectDir, ".env");
|
|
47
|
+
if (await fs.pathExists(envExample)) {
|
|
48
|
+
await fs.copy(envExample, envDest);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
replaceScope,
|
|
54
|
+
setupEnv
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=chunk-GB72MU2M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/transform.ts"],"sourcesContent":["import fg from 'fast-glob';\r\nimport fs from 'fs-extra';\r\nimport path from 'path';\r\nimport { spinner } from '@clack/prompts';\r\nimport color from 'picocolors';\r\n\r\nexport async function replaceScope(projectDir: string, newScope: string) {\r\n const s = spinner();\r\n s.start(`Replacing scope with ${color.cyan(newScope)}...`);\r\n\r\n try {\r\n const files = await fg('**/*', {\r\n cwd: projectDir,\r\n ignore: [\r\n '**/.git/**',\r\n '**/node_modules/**',\r\n '**/.turbo/**',\r\n '**/dist/**',\r\n '**/.next/**',\r\n '**/pnpm-lock.yaml',\r\n '**/yarn.lock',\r\n '**/package-lock.json',\r\n '**/bun.lockb',\r\n ],\r\n absolute: true,\r\n });\r\n\r\n await Promise.all(\r\n files.map(async (file) => {\r\n try {\r\n const content = await fs.readFile(file, 'utf8');\r\n if (content.includes('@acme')) {\r\n const newContent = content.replace(/@acme/g, newScope);\r\n await fs.writeFile(file, newContent);\r\n }\r\n } catch (e) {\r\n }\r\n })\r\n );\r\n \r\n s.stop(`Replaced scope with ${color.cyan(newScope)}`);\r\n } catch (error) {\r\n s.stop('Failed to replace scope');\r\n throw error;\r\n }\r\n}\r\n\r\nexport async function setupEnv(projectDir: string) {\r\n const envExample = path.join(projectDir, '.env.example');\r\n const envDest = path.join(projectDir, '.env');\r\n\r\n if (await fs.pathExists(envExample)) {\r\n await fs.copy(envExample, envDest);\r\n }\r\n}\r\n\r\n"],"mappings":";AAAA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,OAAO,WAAW;AAElB,eAAsB,aAAa,YAAoB,UAAkB;AACvE,QAAM,IAAI,QAAQ;AAClB,IAAE,MAAM,wBAAwB,MAAM,KAAK,QAAQ,CAAC,KAAK;AAEzD,MAAI;AACF,UAAM,QAAQ,MAAM,GAAG,QAAQ;AAAA,MAC7B,KAAK;AAAA,MACL,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,UAAU;AAAA,IACZ,CAAC;AAED,UAAM,QAAQ;AAAA,MACZ,MAAM,IAAI,OAAO,SAAS;AACxB,YAAI;AACF,gBAAM,UAAU,MAAM,GAAG,SAAS,MAAM,MAAM;AAC9C,cAAI,QAAQ,SAAS,OAAO,GAAG;AAC7B,kBAAM,aAAa,QAAQ,QAAQ,UAAU,QAAQ;AACrD,kBAAM,GAAG,UAAU,MAAM,UAAU;AAAA,UACrC;AAAA,QACF,SAAS,GAAG;AAAA,QACZ;AAAA,MACF,CAAC;AAAA,IACH;AAEA,MAAE,KAAK,uBAAuB,MAAM,KAAK,QAAQ,CAAC,EAAE;AAAA,EACtD,SAAS,OAAO;AACd,MAAE,KAAK,yBAAyB;AAChC,UAAM;AAAA,EACR;AACF;AAEA,eAAsB,SAAS,YAAoB;AACjD,QAAM,aAAa,KAAK,KAAK,YAAY,cAAc;AACvD,QAAM,UAAU,KAAK,KAAK,YAAY,MAAM;AAE5C,MAAI,MAAM,GAAG,WAAW,UAAU,GAAG;AACnC,UAAM,GAAG,KAAK,YAAY,OAAO;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getRunner
|
|
3
|
+
} from "./chunk-EYEU3RGM.js";
|
|
4
|
+
|
|
5
|
+
// src/helpers/scaffold.ts
|
|
6
|
+
import { execa } from "execa";
|
|
7
|
+
import { spinner } from "@clack/prompts";
|
|
8
|
+
import color from "picocolors";
|
|
9
|
+
async function scaffoldProject({ projectName, packageManager }) {
|
|
10
|
+
const s = spinner();
|
|
11
|
+
s.start(`Scaffolding project in ${color.cyan(projectName)}...`);
|
|
12
|
+
const runner = getRunner(packageManager);
|
|
13
|
+
const [command = "npx", ...args] = runner.split(" ");
|
|
14
|
+
try {
|
|
15
|
+
await execa(command, [
|
|
16
|
+
...args,
|
|
17
|
+
"create-turbo@latest",
|
|
18
|
+
"-e",
|
|
19
|
+
"https://github.com/Badbird5907/turbo-kit",
|
|
20
|
+
"--package-manager",
|
|
21
|
+
packageManager,
|
|
22
|
+
"--skip-install",
|
|
23
|
+
projectName
|
|
24
|
+
]);
|
|
25
|
+
s.stop(`Scaffolded project in ${color.cyan(projectName)}`);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
s.stop(`Failed to scaffold project`);
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
scaffoldProject
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-MBDFMIAE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helpers/scaffold.ts"],"sourcesContent":["import { execa } from 'execa';\r\nimport { spinner } from '@clack/prompts';\r\nimport { type PackageManager, getRunner } from '../utils/package-manager.js';\r\nimport color from 'picocolors';\r\n\r\nexport interface ScaffoldOptions {\r\n projectName: string;\r\n packageManager: PackageManager;\r\n}\r\n\r\nexport async function scaffoldProject({ projectName, packageManager }: ScaffoldOptions) {\r\n const s = spinner();\r\n s.start(`Scaffolding project in ${color.cyan(projectName)}...`);\r\n\r\n const runner = getRunner(packageManager);\r\n const [command = 'npx', ...args] = runner.split(' ');\r\n \r\n try {\r\n await execa(command, [\r\n ...args,\r\n 'create-turbo@latest',\r\n '-e',\r\n 'https://github.com/Badbird5907/turbo-kit',\r\n '--package-manager',\r\n packageManager,\r\n '--skip-install',\r\n projectName\r\n ]);\r\n \r\n s.stop(`Scaffolded project in ${color.cyan(projectName)}`);\r\n } catch (error) {\r\n s.stop(`Failed to scaffold project`);\r\n throw error;\r\n }\r\n}\r\n\r\n"],"mappings":";;;;;AAAA,SAAS,aAAa;AACtB,SAAS,eAAe;AAExB,OAAO,WAAW;AAOlB,eAAsB,gBAAgB,EAAE,aAAa,eAAe,GAAoB;AACtF,QAAM,IAAI,QAAQ;AAClB,IAAE,MAAM,0BAA0B,MAAM,KAAK,WAAW,CAAC,KAAK;AAE9D,QAAM,SAAS,UAAU,cAAc;AACvC,QAAM,CAAC,UAAU,OAAO,GAAG,IAAI,IAAI,OAAO,MAAM,GAAG;AAEnD,MAAI;AACF,UAAM,MAAM,SAAS;AAAA,MACnB,GAAG;AAAA,MACH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAED,MAAE,KAAK,yBAAyB,MAAM,KAAK,WAAW,CAAC,EAAE;AAAA,EAC3D,SAAS,OAAO;AACd,MAAE,KAAK,4BAA4B;AACnC,UAAM;AAAA,EACR;AACF;","names":[]}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installDependencies
|
|
3
|
+
} from "./chunk-G5KXW3XA.js";
|
|
4
|
+
import {
|
|
5
|
+
scaffoldProject
|
|
6
|
+
} from "./chunk-MBDFMIAE.js";
|
|
7
|
+
import {
|
|
8
|
+
replaceScope,
|
|
9
|
+
setupEnv
|
|
10
|
+
} from "./chunk-GB72MU2M.js";
|
|
11
|
+
import "./chunk-EYEU3RGM.js";
|
|
12
|
+
|
|
13
|
+
// src/cli.ts
|
|
14
|
+
import { intro, outro, text, select, isCancel, cancel, confirm } from "@clack/prompts";
|
|
15
|
+
import { Command } from "commander";
|
|
16
|
+
import color from "picocolors";
|
|
17
|
+
import fs from "fs-extra";
|
|
18
|
+
import path from "path";
|
|
19
|
+
async function main() {
|
|
20
|
+
const program = new Command();
|
|
21
|
+
program.name("create-turbo-kit").description("Initialize a custom turborepo template").argument("[project-name]", "Name of the project directory").parse(process.argv);
|
|
22
|
+
const args = program.args;
|
|
23
|
+
let projectName = args[0];
|
|
24
|
+
console.log();
|
|
25
|
+
intro(color.bgCyan(color.black(" Create Turbo Kit ")));
|
|
26
|
+
if (!projectName) {
|
|
27
|
+
const pName = await text({
|
|
28
|
+
message: "What is your project named?",
|
|
29
|
+
placeholder: "my-turbo-app",
|
|
30
|
+
validate: (value) => {
|
|
31
|
+
if (!value) return "Please enter a name.";
|
|
32
|
+
if (/[^a-zA-Z0-9-_]/.test(value)) return "Project name can only contain letters, numbers, dashes and underscores.";
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (isCancel(pName)) {
|
|
36
|
+
cancel("Operation cancelled.");
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
projectName = pName;
|
|
40
|
+
}
|
|
41
|
+
const projectDir = path.resolve(process.cwd(), projectName);
|
|
42
|
+
if (await fs.pathExists(projectDir)) {
|
|
43
|
+
const shouldOverwrite = await confirm({
|
|
44
|
+
message: `Directory ${projectName} already exists. Do you want to overwrite it?`,
|
|
45
|
+
initialValue: false
|
|
46
|
+
});
|
|
47
|
+
if (isCancel(shouldOverwrite) || !shouldOverwrite) {
|
|
48
|
+
cancel("Operation cancelled.");
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
await fs.remove(projectDir);
|
|
52
|
+
}
|
|
53
|
+
const packageManager = await select({
|
|
54
|
+
message: "Which package manager do you want to use?",
|
|
55
|
+
options: [
|
|
56
|
+
{ value: "pnpm", label: "pnpm" },
|
|
57
|
+
{ value: "npm", label: "npm" },
|
|
58
|
+
{ value: "yarn", label: "yarn" },
|
|
59
|
+
{ value: "bun", label: "bun" }
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
if (isCancel(packageManager)) {
|
|
63
|
+
cancel("Operation cancelled.");
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
const getScope = async () => {
|
|
67
|
+
const scope2 = await text({
|
|
68
|
+
message: "What is your package scope?",
|
|
69
|
+
placeholder: "@my-org",
|
|
70
|
+
validate: (value) => {
|
|
71
|
+
if (!value) return "Please enter a scope.";
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (isCancel(scope2)) {
|
|
75
|
+
cancel("Operation cancelled.");
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
const check = ["@", "~", "$", "#", "!"];
|
|
79
|
+
if (!check.includes(scope2[0])) {
|
|
80
|
+
const importStatement = `${color.magenta("import")} ${color.yellow("{")} ${color.cyan("example")} ${color.yellow("}")} ${color.magenta("from")} ${color.cyan(`"${scope2}/example"`)}`;
|
|
81
|
+
const confirmScope = await confirm({
|
|
82
|
+
message: `Is ${color.cyan(scope2)} the correct scope?
|
|
83
|
+
Your import statements will look like this: ${importStatement}`,
|
|
84
|
+
initialValue: true
|
|
85
|
+
});
|
|
86
|
+
if (isCancel(confirmScope) || !confirmScope) {
|
|
87
|
+
return await getScope();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return scope2;
|
|
91
|
+
};
|
|
92
|
+
const scope = await getScope();
|
|
93
|
+
try {
|
|
94
|
+
await scaffoldProject({
|
|
95
|
+
projectName,
|
|
96
|
+
packageManager
|
|
97
|
+
});
|
|
98
|
+
await replaceScope(projectDir, scope);
|
|
99
|
+
await setupEnv(projectDir);
|
|
100
|
+
await installDependencies(projectDir, packageManager);
|
|
101
|
+
outro(color.green("Project initialized successfully!"));
|
|
102
|
+
console.log(`To get started:`);
|
|
103
|
+
console.log(color.cyan(` cd ${projectName}`));
|
|
104
|
+
console.log(color.cyan(` ${packageManager} run dev`));
|
|
105
|
+
console.log();
|
|
106
|
+
console.log(color.greenBright("Happy Hacking!"));
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(color.red("An error occurred:"), error);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
main().catch(console.error);
|
|
113
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["import { intro, outro, text, select, isCancel, cancel, confirm } from '@clack/prompts';\r\nimport { Command } from 'commander';\r\nimport color from 'picocolors';\r\nimport fs from 'fs-extra';\r\nimport path from 'path';\r\nimport { replaceScope, setupEnv } from './helpers/transform.js';\r\nimport { installDependencies } from './helpers/install.js';\r\nimport { type PackageManager } from './utils/package-manager.js';\r\nimport { scaffoldProject } from './helpers/scaffold.js';\r\n\r\nasync function main() {\r\n const program = new Command();\r\n \r\n program\r\n .name('create-turbo-kit')\r\n .description('Initialize a custom turborepo template')\r\n .argument('[project-name]', 'Name of the project directory')\r\n .parse(process.argv);\r\n\r\n const args = program.args;\r\n let projectName = args[0];\r\n\r\n console.log();\r\n intro(color.bgCyan(color.black(' Create Turbo Kit ')));\r\n\r\n if (!projectName) {\r\n const pName = await text({\r\n message: 'What is your project named?',\r\n placeholder: 'my-turbo-app',\r\n validate: (value) => {\r\n if (!value) return 'Please enter a name.';\r\n if (/[^a-zA-Z0-9-_]/.test(value)) return 'Project name can only contain letters, numbers, dashes and underscores.';\r\n },\r\n });\r\n\r\n if (isCancel(pName)) {\r\n cancel('Operation cancelled.');\r\n process.exit(0);\r\n }\r\n projectName = pName as string;\r\n }\r\n\r\n const projectDir = path.resolve(process.cwd(), projectName);\r\n\r\n if (await fs.pathExists(projectDir)) {\r\n const shouldOverwrite = await confirm({\r\n message: `Directory ${projectName} already exists. Do you want to overwrite it?`,\r\n initialValue: false,\r\n });\r\n\r\n if (isCancel(shouldOverwrite) || !shouldOverwrite) {\r\n cancel('Operation cancelled.');\r\n process.exit(0);\r\n }\r\n \r\n await fs.remove(projectDir);\r\n }\r\n\r\n const packageManager = await select({\r\n message: 'Which package manager do you want to use?',\r\n options: [\r\n { value: 'pnpm', label: 'pnpm' },\r\n { value: 'npm', label: 'npm' },\r\n { value: 'yarn', label: 'yarn' },\r\n { value: 'bun', label: 'bun' },\r\n ],\r\n });\r\n\r\n if (isCancel(packageManager)) {\r\n cancel('Operation cancelled.');\r\n process.exit(0);\r\n }\r\n\r\n const getScope = async (): Promise<string> => {\r\n const scope = await text({\r\n message: 'What is your package scope?',\r\n placeholder: '@my-org',\r\n validate: (value) => {\r\n if (!value) return 'Please enter a scope.';\r\n },\r\n });\r\n \r\n if (isCancel(scope)) {\r\n cancel('Operation cancelled.');\r\n process.exit(0);\r\n }\r\n\r\n const check = [\"@\", \"~\", \"$\", \"#\", \"!\"];\r\n if (!check.includes(scope[0] as string)) {\r\n // ask the user to confirm this is the correct scope\r\n const importStatement = `${color.magenta(\"import\")} ${color.yellow(\"{\")} ${color.cyan(\"example\")} ${color.yellow(\"}\")} ${color.magenta(\"from\")} ${color.cyan(`\"${scope}/example\"`)}`;\r\n const confirmScope = await confirm({\r\n message: `Is ${color.cyan(scope)} the correct scope?\\nYour import statements will look like this: ${importStatement}`,\r\n initialValue: true,\r\n });\r\n if (isCancel(confirmScope) || !confirmScope) {\r\n return await getScope();\r\n }\r\n }\r\n\r\n return scope as string;\r\n }\r\n const scope = await getScope();\r\n\r\n try {\r\n await scaffoldProject({\r\n projectName,\r\n packageManager: packageManager as PackageManager,\r\n });\r\n\r\n await replaceScope(projectDir, scope as string);\r\n await setupEnv(projectDir);\r\n await installDependencies(projectDir, packageManager as PackageManager);\r\n\r\n outro(color.green('Project initialized successfully!'));\r\n \r\n console.log(`To get started:`);\r\n console.log(color.cyan(` cd ${projectName}`));\r\n console.log(color.cyan(` ${packageManager} run dev`));\r\n \r\n console.log();\r\n console.log(color.greenBright(\"Happy Hacking!\"))\r\n } catch (error) {\r\n console.error(color.red('An error occurred:'), error);\r\n process.exit(1);\r\n }\r\n}\r\n\r\nmain().catch(console.error);\r\n"],"mappings":"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","names":["scope"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PackageManager } from '../utils/package-manager.js';
|
|
2
|
+
|
|
3
|
+
interface ScaffoldOptions {
|
|
4
|
+
projectName: string;
|
|
5
|
+
packageManager: PackageManager;
|
|
6
|
+
}
|
|
7
|
+
declare function scaffoldProject({ projectName, packageManager }: ScaffoldOptions): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export { type ScaffoldOptions, scaffoldProject };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-turbo-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
|
-
"main": "dist/cli.
|
|
6
|
+
"main": "dist/cli.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-turbo-kit": "dist/cli.js"
|
|
9
|
+
},
|
|
7
10
|
"keywords": [],
|
|
8
11
|
"author": "",
|
|
9
12
|
"license": "ISC",
|
package/tsup.config.ts
ADDED
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);
|
package/dist/helpers/install.cjs
DELETED
|
@@ -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
|
-
});
|
|
@@ -1,90 +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/transform.ts
|
|
31
|
-
var transform_exports = {};
|
|
32
|
-
__export(transform_exports, {
|
|
33
|
-
replaceScope: () => replaceScope,
|
|
34
|
-
setupEnv: () => setupEnv
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(transform_exports);
|
|
37
|
-
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
38
|
-
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
39
|
-
var import_path = __toESM(require("path"), 1);
|
|
40
|
-
var import_prompts = require("@clack/prompts");
|
|
41
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
42
|
-
async function replaceScope(projectDir, newScope) {
|
|
43
|
-
const s = (0, import_prompts.spinner)();
|
|
44
|
-
s.start(`Replacing scope with ${import_picocolors.default.cyan(newScope)}...`);
|
|
45
|
-
try {
|
|
46
|
-
const files = await (0, import_fast_glob.default)("**/*", {
|
|
47
|
-
cwd: projectDir,
|
|
48
|
-
ignore: [
|
|
49
|
-
"**/.git/**",
|
|
50
|
-
"**/node_modules/**",
|
|
51
|
-
"**/.turbo/**",
|
|
52
|
-
"**/dist/**",
|
|
53
|
-
"**/.next/**",
|
|
54
|
-
"**/pnpm-lock.yaml",
|
|
55
|
-
"**/yarn.lock",
|
|
56
|
-
"**/package-lock.json",
|
|
57
|
-
"**/bun.lockb"
|
|
58
|
-
],
|
|
59
|
-
absolute: true
|
|
60
|
-
});
|
|
61
|
-
await Promise.all(
|
|
62
|
-
files.map(async (file) => {
|
|
63
|
-
try {
|
|
64
|
-
const content = await import_fs_extra.default.readFile(file, "utf8");
|
|
65
|
-
if (content.includes("@acme")) {
|
|
66
|
-
const newContent = content.replace(/@acme/g, newScope);
|
|
67
|
-
await import_fs_extra.default.writeFile(file, newContent);
|
|
68
|
-
}
|
|
69
|
-
} catch (e) {
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
s.stop(`Replaced scope with ${import_picocolors.default.cyan(newScope)}`);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
s.stop("Failed to replace scope");
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async function setupEnv(projectDir) {
|
|
80
|
-
const envExample = import_path.default.join(projectDir, ".env.example");
|
|
81
|
-
const envDest = import_path.default.join(projectDir, ".env");
|
|
82
|
-
if (await import_fs_extra.default.pathExists(envExample)) {
|
|
83
|
-
await import_fs_extra.default.copy(envExample, envDest);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
-
0 && (module.exports = {
|
|
88
|
-
replaceScope,
|
|
89
|
-
setupEnv
|
|
90
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/utils/package-manager.ts
|
|
21
|
-
var package_manager_exports = {};
|
|
22
|
-
__export(package_manager_exports, {
|
|
23
|
-
getInstallCommand: () => getInstallCommand,
|
|
24
|
-
getRunner: () => getRunner
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(package_manager_exports);
|
|
27
|
-
function getRunner(pm) {
|
|
28
|
-
switch (pm) {
|
|
29
|
-
case "npm":
|
|
30
|
-
return "npx";
|
|
31
|
-
case "pnpm":
|
|
32
|
-
return "pnpm dlx";
|
|
33
|
-
case "yarn":
|
|
34
|
-
return "yarn dlx";
|
|
35
|
-
case "bun":
|
|
36
|
-
return "bunx";
|
|
37
|
-
default:
|
|
38
|
-
return "npx";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function getInstallCommand(pm) {
|
|
42
|
-
switch (pm) {
|
|
43
|
-
case "npm":
|
|
44
|
-
return "npm install";
|
|
45
|
-
case "pnpm":
|
|
46
|
-
return "pnpm install";
|
|
47
|
-
case "yarn":
|
|
48
|
-
return "yarn install";
|
|
49
|
-
case "bun":
|
|
50
|
-
return "bun install";
|
|
51
|
-
default:
|
|
52
|
-
return "npm install";
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
getInstallCommand,
|
|
58
|
-
getRunner
|
|
59
|
-
});
|