create-turbo-kit 1.0.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/dist/cli.cjs +256 -0
- package/dist/helpers/install.cjs +75 -0
- package/dist/helpers/scaffold.cjs +82 -0
- package/dist/helpers/transform.cjs +90 -0
- package/dist/utils/package-manager.cjs +59 -0
- package/package.json +29 -0
- package/src/cli.ts +129 -0
- package/src/helpers/install.ts +23 -0
- package/src/helpers/scaffold.ts +36 -0
- package/src/helpers/transform.ts +56 -0
- package/src/utils/package-manager.ts +32 -0
- package/tsconfig.json +48 -0
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
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-template",
|
|
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);
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
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-template",
|
|
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
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-turbo-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "dist/cli.cjs",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/fs-extra": "^11.0.4",
|
|
12
|
+
"@types/node": "^25.0.1",
|
|
13
|
+
"tsup": "^8.5.1",
|
|
14
|
+
"tsx": "^4.21.0",
|
|
15
|
+
"typescript": "^5.9.3"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@clack/prompts": "^0.11.0",
|
|
19
|
+
"commander": "^14.0.2",
|
|
20
|
+
"execa": "^9.6.1",
|
|
21
|
+
"fast-glob": "^3.3.3",
|
|
22
|
+
"fs-extra": "^11.3.2",
|
|
23
|
+
"picocolors": "^1.1.1"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup src",
|
|
27
|
+
"dev": "tsx src/cli.ts"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { intro, outro, text, select, isCancel, cancel, confirm } from '@clack/prompts';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import color from 'picocolors';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { replaceScope, setupEnv } from './helpers/transform.js';
|
|
7
|
+
import { installDependencies } from './helpers/install.js';
|
|
8
|
+
import { type PackageManager } from './utils/package-manager.js';
|
|
9
|
+
import { scaffoldProject } from './helpers/scaffold.js';
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
const program = new Command();
|
|
13
|
+
|
|
14
|
+
program
|
|
15
|
+
.name('create-turbo-kit')
|
|
16
|
+
.description('Initialize a custom turborepo template')
|
|
17
|
+
.argument('[project-name]', 'Name of the project directory')
|
|
18
|
+
.parse(process.argv);
|
|
19
|
+
|
|
20
|
+
const args = program.args;
|
|
21
|
+
let projectName = args[0];
|
|
22
|
+
|
|
23
|
+
console.log();
|
|
24
|
+
intro(color.bgCyan(color.black(' Create Turbo Kit ')));
|
|
25
|
+
|
|
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
|
+
|
|
36
|
+
if (isCancel(pName)) {
|
|
37
|
+
cancel('Operation cancelled.');
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
projectName = pName as string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const projectDir = path.resolve(process.cwd(), projectName);
|
|
44
|
+
|
|
45
|
+
if (await fs.pathExists(projectDir)) {
|
|
46
|
+
const shouldOverwrite = await confirm({
|
|
47
|
+
message: `Directory ${projectName} already exists. Do you want to overwrite it?`,
|
|
48
|
+
initialValue: false,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (isCancel(shouldOverwrite) || !shouldOverwrite) {
|
|
52
|
+
cancel('Operation cancelled.');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await fs.remove(projectDir);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const packageManager = await select({
|
|
60
|
+
message: 'Which package manager do you want to use?',
|
|
61
|
+
options: [
|
|
62
|
+
{ value: 'pnpm', label: 'pnpm' },
|
|
63
|
+
{ value: 'npm', label: 'npm' },
|
|
64
|
+
{ value: 'yarn', label: 'yarn' },
|
|
65
|
+
{ value: 'bun', label: 'bun' },
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (isCancel(packageManager)) {
|
|
70
|
+
cancel('Operation cancelled.');
|
|
71
|
+
process.exit(0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const getScope = async (): Promise<string> => {
|
|
75
|
+
const scope = await text({
|
|
76
|
+
message: 'What is your package scope?',
|
|
77
|
+
placeholder: '@my-org',
|
|
78
|
+
validate: (value) => {
|
|
79
|
+
if (!value) return 'Please enter a scope.';
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (isCancel(scope)) {
|
|
84
|
+
cancel('Operation cancelled.');
|
|
85
|
+
process.exit(0);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const check = ["@", "~", "$", "#", "!"];
|
|
89
|
+
if (!check.includes(scope[0] as string)) {
|
|
90
|
+
// ask the user to confirm this is the correct scope
|
|
91
|
+
const importStatement = `${color.magenta("import")} ${color.yellow("{")} ${color.cyan("example")} ${color.yellow("}")} ${color.magenta("from")} ${color.cyan(`"${scope}/example"`)}`;
|
|
92
|
+
const confirmScope = await confirm({
|
|
93
|
+
message: `Is ${color.cyan(scope)} the correct scope?\nYour import statements will look like this: ${importStatement}`,
|
|
94
|
+
initialValue: true,
|
|
95
|
+
});
|
|
96
|
+
if (isCancel(confirmScope) || !confirmScope) {
|
|
97
|
+
return await getScope();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return scope as string;
|
|
102
|
+
}
|
|
103
|
+
const scope = await getScope();
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
await scaffoldProject({
|
|
107
|
+
projectName,
|
|
108
|
+
packageManager: packageManager as PackageManager,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
await replaceScope(projectDir, scope as string);
|
|
112
|
+
await setupEnv(projectDir);
|
|
113
|
+
await installDependencies(projectDir, packageManager as PackageManager);
|
|
114
|
+
|
|
115
|
+
outro(color.green('Project initialized successfully!'));
|
|
116
|
+
|
|
117
|
+
console.log(`To get started:`);
|
|
118
|
+
console.log(color.cyan(` cd ${projectName}`));
|
|
119
|
+
console.log(color.cyan(` ${packageManager} run dev`));
|
|
120
|
+
|
|
121
|
+
console.log();
|
|
122
|
+
console.log(color.greenBright("Happy Hacking!"))
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error(color.red('An error occurred:'), error);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { spinner } from '@clack/prompts';
|
|
3
|
+
import { type PackageManager, getInstallCommand } from '../utils/package-manager.js';
|
|
4
|
+
import color from 'picocolors';
|
|
5
|
+
|
|
6
|
+
export async function installDependencies(projectDir: string, packageManager: PackageManager) {
|
|
7
|
+
const s = spinner();
|
|
8
|
+
s.start(`Installing dependencies with ${color.cyan(packageManager)}...`);
|
|
9
|
+
|
|
10
|
+
const installCmd = getInstallCommand(packageManager);
|
|
11
|
+
const [command = "npm", ...args] = installCmd.split(' ');
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
await execa(command, args, {
|
|
15
|
+
cwd: projectDir,
|
|
16
|
+
});
|
|
17
|
+
s.stop(`Installed dependencies`);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
s.stop(`Failed to install dependencies`);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { spinner } from '@clack/prompts';
|
|
3
|
+
import { type PackageManager, getRunner } from '../utils/package-manager.js';
|
|
4
|
+
import color from 'picocolors';
|
|
5
|
+
|
|
6
|
+
export interface ScaffoldOptions {
|
|
7
|
+
projectName: string;
|
|
8
|
+
packageManager: PackageManager;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function scaffoldProject({ projectName, packageManager }: ScaffoldOptions) {
|
|
12
|
+
const s = spinner();
|
|
13
|
+
s.start(`Scaffolding project in ${color.cyan(projectName)}...`);
|
|
14
|
+
|
|
15
|
+
const runner = getRunner(packageManager);
|
|
16
|
+
const [command = 'npx', ...args] = runner.split(' ');
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await execa(command, [
|
|
20
|
+
...args,
|
|
21
|
+
'create-turbo@latest',
|
|
22
|
+
'-e',
|
|
23
|
+
'https://github.com/Badbird5907/turbo-template',
|
|
24
|
+
'--package-manager',
|
|
25
|
+
packageManager,
|
|
26
|
+
'--skip-install',
|
|
27
|
+
projectName
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
s.stop(`Scaffolded project in ${color.cyan(projectName)}`);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
s.stop(`Failed to scaffold project`);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fg from 'fast-glob';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { spinner } from '@clack/prompts';
|
|
5
|
+
import color from 'picocolors';
|
|
6
|
+
|
|
7
|
+
export async function replaceScope(projectDir: string, newScope: string) {
|
|
8
|
+
const s = spinner();
|
|
9
|
+
s.start(`Replacing scope with ${color.cyan(newScope)}...`);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const files = await fg('**/*', {
|
|
13
|
+
cwd: projectDir,
|
|
14
|
+
ignore: [
|
|
15
|
+
'**/.git/**',
|
|
16
|
+
'**/node_modules/**',
|
|
17
|
+
'**/.turbo/**',
|
|
18
|
+
'**/dist/**',
|
|
19
|
+
'**/.next/**',
|
|
20
|
+
'**/pnpm-lock.yaml',
|
|
21
|
+
'**/yarn.lock',
|
|
22
|
+
'**/package-lock.json',
|
|
23
|
+
'**/bun.lockb',
|
|
24
|
+
],
|
|
25
|
+
absolute: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await Promise.all(
|
|
29
|
+
files.map(async (file) => {
|
|
30
|
+
try {
|
|
31
|
+
const content = await fs.readFile(file, 'utf8');
|
|
32
|
+
if (content.includes('@acme')) {
|
|
33
|
+
const newContent = content.replace(/@acme/g, newScope);
|
|
34
|
+
await fs.writeFile(file, newContent);
|
|
35
|
+
}
|
|
36
|
+
} catch (e) {
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
s.stop(`Replaced scope with ${color.cyan(newScope)}`);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
s.stop('Failed to replace scope');
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function setupEnv(projectDir: string) {
|
|
49
|
+
const envExample = path.join(projectDir, '.env.example');
|
|
50
|
+
const envDest = path.join(projectDir, '.env');
|
|
51
|
+
|
|
52
|
+
if (await fs.pathExists(envExample)) {
|
|
53
|
+
await fs.copy(envExample, envDest);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
|
|
2
|
+
|
|
3
|
+
export function getRunner(pm: PackageManager): string {
|
|
4
|
+
switch (pm) {
|
|
5
|
+
case 'npm':
|
|
6
|
+
return 'npx';
|
|
7
|
+
case 'pnpm':
|
|
8
|
+
return 'pnpm dlx';
|
|
9
|
+
case 'yarn':
|
|
10
|
+
return 'yarn dlx';
|
|
11
|
+
case 'bun':
|
|
12
|
+
return 'bunx';
|
|
13
|
+
default:
|
|
14
|
+
return 'npx';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getInstallCommand(pm: PackageManager): string {
|
|
19
|
+
switch (pm) {
|
|
20
|
+
case 'npm':
|
|
21
|
+
return 'npm install';
|
|
22
|
+
case 'pnpm':
|
|
23
|
+
return 'pnpm install';
|
|
24
|
+
case 'yarn':
|
|
25
|
+
return 'yarn install';
|
|
26
|
+
case 'bun':
|
|
27
|
+
return 'bun install';
|
|
28
|
+
default:
|
|
29
|
+
return 'npm install';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": [],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
|
|
44
|
+
"paths": {
|
|
45
|
+
"@/*": ["./src/*"]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|