create-turbo 1.6.0-canary.1 → 1.6.0-canary.3
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/dist/index.js +0 -464
package/package.json
CHANGED
package/dist/index.js
DELETED
@@ -1,464 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
"use strict";
|
3
|
-
var __create = Object.create;
|
4
|
-
var __defProp = Object.defineProperty;
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
-
for (let key of __getOwnPropNames(from))
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
18
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
19
|
-
mod
|
20
|
-
));
|
21
|
-
|
22
|
-
// src/index.ts
|
23
|
-
var path2 = __toESM(require("path"));
|
24
|
-
var import_execa = __toESM(require("execa"));
|
25
|
-
var import_fs = __toESM(require("fs"));
|
26
|
-
var import_inquirer = __toESM(require("inquirer"));
|
27
|
-
var import_ora = __toESM(require("ora"));
|
28
|
-
var import_meow = __toESM(require("meow"));
|
29
|
-
var import_semver = require("semver");
|
30
|
-
var import_gradient_string = __toESM(require("gradient-string"));
|
31
|
-
var import_update_check = __toESM(require("update-check"));
|
32
|
-
var import_chalk = __toESM(require("chalk"));
|
33
|
-
|
34
|
-
// package.json
|
35
|
-
var package_default = {
|
36
|
-
name: "create-turbo",
|
37
|
-
version: "1.6.0-canary.1",
|
38
|
-
description: "Create a new Turborepo",
|
39
|
-
homepage: "https://turborepo.org",
|
40
|
-
license: "MPL-2.0",
|
41
|
-
repository: {
|
42
|
-
type: "git",
|
43
|
-
url: "https://github.com/vercel/turborepo",
|
44
|
-
directory: "packages/create-turbo"
|
45
|
-
},
|
46
|
-
bugs: {
|
47
|
-
url: "https://github.com/vercel/turborepo/issues"
|
48
|
-
},
|
49
|
-
bin: {
|
50
|
-
"create-turbo": "dist/index.js"
|
51
|
-
},
|
52
|
-
scripts: {
|
53
|
-
build: "tsup",
|
54
|
-
test: "jest",
|
55
|
-
lint: "eslint src/**/*.ts",
|
56
|
-
"check-types": "tsc --noEmit"
|
57
|
-
},
|
58
|
-
dependencies: {
|
59
|
-
chalk: "2.4.2",
|
60
|
-
execa: "5.1.1",
|
61
|
-
"gradient-string": "^2.0.0",
|
62
|
-
inquirer: "^8.0.0",
|
63
|
-
meow: "^7.1.1",
|
64
|
-
ora: "4.1.1",
|
65
|
-
rimraf: "^3.0.2",
|
66
|
-
semver: "^7.3.5",
|
67
|
-
"update-check": "^1.5.4"
|
68
|
-
},
|
69
|
-
devDependencies: {
|
70
|
-
"@types/chalk-animation": "^1.6.0",
|
71
|
-
"@types/gradient-string": "^1.1.2",
|
72
|
-
"@types/inquirer": "^7.3.1",
|
73
|
-
"@types/jest": "^27.4.0",
|
74
|
-
"@types/node": "^16.11.12",
|
75
|
-
"@types/rimraf": "^3.0.2",
|
76
|
-
"@types/semver": "^7.3.9",
|
77
|
-
eslint: "^7.23.0",
|
78
|
-
jest: "^27.4.3",
|
79
|
-
semver: "^7.3.5",
|
80
|
-
"strip-ansi": "^6.0.1",
|
81
|
-
"ts-jest": "^27.1.1",
|
82
|
-
tsconfig: "workspace:*",
|
83
|
-
tsup: "^5.10.3",
|
84
|
-
typescript: "^4.5.5"
|
85
|
-
},
|
86
|
-
files: [
|
87
|
-
"dist",
|
88
|
-
"templates"
|
89
|
-
]
|
90
|
-
};
|
91
|
-
|
92
|
-
// src/shouldUseYarn.ts
|
93
|
-
var import_child_process = require("child_process");
|
94
|
-
function shouldUseYarn() {
|
95
|
-
try {
|
96
|
-
const userAgent = process.env.npm_config_user_agent;
|
97
|
-
if (userAgent && userAgent.startsWith("yarn")) {
|
98
|
-
return true;
|
99
|
-
}
|
100
|
-
(0, import_child_process.execSync)("yarnpkg --version", { stdio: "ignore" });
|
101
|
-
return true;
|
102
|
-
} catch (e) {
|
103
|
-
return false;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
// src/shouldUsePnpm.ts
|
108
|
-
var import_child_process2 = require("child_process");
|
109
|
-
function shouldUsePnpm() {
|
110
|
-
try {
|
111
|
-
const userAgent = process.env.npm_config_user_agent;
|
112
|
-
if (userAgent && userAgent.startsWith("pnpm")) {
|
113
|
-
return true;
|
114
|
-
}
|
115
|
-
(0, import_child_process2.execSync)("pnpm --version", { stdio: "ignore" });
|
116
|
-
return true;
|
117
|
-
} catch (e) {
|
118
|
-
return false;
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
// src/git.ts
|
123
|
-
var import_child_process3 = require("child_process");
|
124
|
-
var import_path = __toESM(require("path"));
|
125
|
-
var import_rimraf = __toESM(require("rimraf"));
|
126
|
-
function isInGitRepository() {
|
127
|
-
try {
|
128
|
-
(0, import_child_process3.execSync)("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
|
129
|
-
return true;
|
130
|
-
} catch (_) {
|
131
|
-
}
|
132
|
-
return false;
|
133
|
-
}
|
134
|
-
function isInMercurialRepository() {
|
135
|
-
try {
|
136
|
-
(0, import_child_process3.execSync)("hg --cwd . root", { stdio: "ignore" });
|
137
|
-
return true;
|
138
|
-
} catch (_) {
|
139
|
-
}
|
140
|
-
return false;
|
141
|
-
}
|
142
|
-
function tryGitInit(root) {
|
143
|
-
let didInit = false;
|
144
|
-
try {
|
145
|
-
(0, import_child_process3.execSync)("git --version", { stdio: "ignore" });
|
146
|
-
if (isInGitRepository() || isInMercurialRepository()) {
|
147
|
-
return false;
|
148
|
-
}
|
149
|
-
(0, import_child_process3.execSync)("git init", { stdio: "ignore" });
|
150
|
-
didInit = true;
|
151
|
-
(0, import_child_process3.execSync)("git checkout -b main", { stdio: "ignore" });
|
152
|
-
(0, import_child_process3.execSync)("git add -A", { stdio: "ignore" });
|
153
|
-
(0, import_child_process3.execSync)('git commit -m "Initial commit from Create Turborepo"', {
|
154
|
-
stdio: "ignore"
|
155
|
-
});
|
156
|
-
return true;
|
157
|
-
} catch (e) {
|
158
|
-
if (didInit) {
|
159
|
-
try {
|
160
|
-
import_rimraf.default.sync(import_path.default.join(root, ".git"));
|
161
|
-
} catch (_) {
|
162
|
-
}
|
163
|
-
}
|
164
|
-
return false;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
// src/constants.ts
|
169
|
-
var PACKAGE_MANAGERS = {
|
170
|
-
npm: [
|
171
|
-
{
|
172
|
-
name: "npm",
|
173
|
-
template: "npm",
|
174
|
-
command: "npm",
|
175
|
-
installArgs: ["install"],
|
176
|
-
version: "latest",
|
177
|
-
executable: "npx",
|
178
|
-
semver: "*"
|
179
|
-
}
|
180
|
-
],
|
181
|
-
pnpm: [
|
182
|
-
{
|
183
|
-
name: "pnpm6",
|
184
|
-
template: "pnpm",
|
185
|
-
command: "pnpm",
|
186
|
-
installArgs: ["install"],
|
187
|
-
version: "latest-6",
|
188
|
-
executable: "pnpx",
|
189
|
-
semver: "6.x"
|
190
|
-
},
|
191
|
-
{
|
192
|
-
name: "pnpm",
|
193
|
-
template: "pnpm",
|
194
|
-
command: "pnpm",
|
195
|
-
installArgs: ["install"],
|
196
|
-
version: "latest",
|
197
|
-
executable: "pnpm dlx",
|
198
|
-
semver: ">=7"
|
199
|
-
}
|
200
|
-
],
|
201
|
-
yarn: [
|
202
|
-
{
|
203
|
-
name: "yarn",
|
204
|
-
template: "yarn",
|
205
|
-
command: "yarn",
|
206
|
-
installArgs: ["install"],
|
207
|
-
version: "1.x",
|
208
|
-
executable: "npx",
|
209
|
-
semver: "<2"
|
210
|
-
},
|
211
|
-
{
|
212
|
-
name: "berry",
|
213
|
-
template: "berry",
|
214
|
-
command: "yarn",
|
215
|
-
installArgs: ["install", "--no-immutable"],
|
216
|
-
version: "stable",
|
217
|
-
executable: "yarn dlx",
|
218
|
-
semver: ">=2"
|
219
|
-
}
|
220
|
-
]
|
221
|
-
};
|
222
|
-
|
223
|
-
// src/getPackageManagerVersion.ts
|
224
|
-
var import_child_process4 = require("child_process");
|
225
|
-
var getPackageManagerVersion = (command) => {
|
226
|
-
return (0, import_child_process4.execSync)(`${command} --version`).toString().trim();
|
227
|
-
};
|
228
|
-
|
229
|
-
// src/index.ts
|
230
|
-
var turboGradient = (0, import_gradient_string.default)("#0099F7", "#F11712");
|
231
|
-
var help = `
|
232
|
-
Usage:
|
233
|
-
$ npx create-turbo [flags...] [<dir>]
|
234
|
-
|
235
|
-
If <dir> is not provided up front you will be prompted for it.
|
236
|
-
|
237
|
-
Flags:
|
238
|
-
--use-npm Explicitly tell the CLI to bootstrap the app using npm
|
239
|
-
--use-pnpm Explicitly tell the CLI to bootstrap the app using pnpm
|
240
|
-
--use-yarn Explicitly tell the CLI to bootstrap the app using yarn
|
241
|
-
--no-install Explicitly do not run the package manager's install command
|
242
|
-
--help, -h Show this help message
|
243
|
-
--version, -v Show the version of this script
|
244
|
-
`;
|
245
|
-
run().then(notifyUpdate).catch(async (reason) => {
|
246
|
-
console.log();
|
247
|
-
console.log("Aborting installation.");
|
248
|
-
if (reason.command) {
|
249
|
-
console.log(` ${import_chalk.default.cyan(reason.command)} has failed.`);
|
250
|
-
} else {
|
251
|
-
console.log(import_chalk.default.red("Unexpected error. Please report it as a bug:"));
|
252
|
-
console.log(reason);
|
253
|
-
}
|
254
|
-
console.log();
|
255
|
-
await notifyUpdate();
|
256
|
-
process.exit(1);
|
257
|
-
});
|
258
|
-
async function run() {
|
259
|
-
let { input, flags, showHelp, showVersion } = (0, import_meow.default)(help, {
|
260
|
-
booleanDefault: void 0,
|
261
|
-
flags: {
|
262
|
-
help: { type: "boolean", default: false, alias: "h" },
|
263
|
-
useNpm: { type: "boolean", default: false },
|
264
|
-
usePnpm: { type: "boolean", default: false },
|
265
|
-
useYarn: { type: "boolean", default: false },
|
266
|
-
install: { type: "boolean", default: true },
|
267
|
-
version: { type: "boolean", default: false, alias: "v" }
|
268
|
-
}
|
269
|
-
});
|
270
|
-
if (flags.help)
|
271
|
-
showHelp();
|
272
|
-
if (flags.version)
|
273
|
-
showVersion();
|
274
|
-
console.log(import_chalk.default.bold(turboGradient(`
|
275
|
-
>>> TURBOREPO
|
276
|
-
`)));
|
277
|
-
await new Promise((resolve2) => setTimeout(resolve2, 500));
|
278
|
-
console.log(
|
279
|
-
">>> Welcome to Turborepo! Let's get you set up with a new codebase."
|
280
|
-
);
|
281
|
-
console.log();
|
282
|
-
let projectDir = path2.resolve(
|
283
|
-
process.cwd(),
|
284
|
-
input.length > 0 ? input[0] : (await import_inquirer.default.prompt([
|
285
|
-
{
|
286
|
-
type: "input",
|
287
|
-
name: "dir",
|
288
|
-
message: "Where would you like to create your turborepo?",
|
289
|
-
default: "./my-turborepo"
|
290
|
-
}
|
291
|
-
])).dir
|
292
|
-
);
|
293
|
-
const projectName = path2.basename(projectDir);
|
294
|
-
const isYarnInstalled = shouldUseYarn();
|
295
|
-
const isPnpmInstalled = shouldUsePnpm();
|
296
|
-
let answers;
|
297
|
-
if (flags.useNpm) {
|
298
|
-
answers = { packageManager: "npm" };
|
299
|
-
} else if (flags.usePnpm) {
|
300
|
-
answers = { packageManager: "pnpm" };
|
301
|
-
} else if (flags.useYarn) {
|
302
|
-
answers = { packageManager: "yarn" };
|
303
|
-
} else {
|
304
|
-
answers = await import_inquirer.default.prompt([
|
305
|
-
{
|
306
|
-
name: "packageManager",
|
307
|
-
type: "list",
|
308
|
-
message: "Which package manager do you want to use?",
|
309
|
-
choices: [
|
310
|
-
{ name: "npm", value: "npm" },
|
311
|
-
{
|
312
|
-
name: "pnpm",
|
313
|
-
value: "pnpm",
|
314
|
-
disabled: !isPnpmInstalled && "not installed"
|
315
|
-
},
|
316
|
-
{
|
317
|
-
name: "yarn",
|
318
|
-
value: "yarn",
|
319
|
-
disabled: !isYarnInstalled && "not installed"
|
320
|
-
}
|
321
|
-
]
|
322
|
-
}
|
323
|
-
]);
|
324
|
-
}
|
325
|
-
let relativeProjectDir = path2.relative(process.cwd(), projectDir);
|
326
|
-
let projectDirIsCurrentDir = relativeProjectDir === "";
|
327
|
-
if (!projectDirIsCurrentDir) {
|
328
|
-
if (import_fs.default.existsSync(projectDir) && import_fs.default.readdirSync(projectDir).length !== 0) {
|
329
|
-
console.log(
|
330
|
-
`\uFE0F\u{1F6A8} Oops, "${relativeProjectDir}" already exists. Please try again with a different directory.`
|
331
|
-
);
|
332
|
-
process.exit(1);
|
333
|
-
} else {
|
334
|
-
import_fs.default.mkdirSync(projectDir, { recursive: true });
|
335
|
-
}
|
336
|
-
}
|
337
|
-
let sharedTemplate = path2.resolve(__dirname, "../templates", `_shared_ts`);
|
338
|
-
import_fs.default.cpSync(sharedTemplate, projectDir, { recursive: true });
|
339
|
-
let packageManagerVersion = getPackageManagerVersion(answers.packageManager);
|
340
|
-
let packageManagerConfigs = PACKAGE_MANAGERS[answers.packageManager];
|
341
|
-
let packageManager = packageManagerConfigs.find(
|
342
|
-
(packageManager2) => (0, import_semver.satisfies)(packageManagerVersion, packageManager2.semver)
|
343
|
-
);
|
344
|
-
if (!packageManager) {
|
345
|
-
throw new Error("Unsupported package manager version.");
|
346
|
-
}
|
347
|
-
let packageManagerTemplate = path2.resolve(
|
348
|
-
__dirname,
|
349
|
-
"../templates",
|
350
|
-
packageManager.template
|
351
|
-
);
|
352
|
-
if (import_fs.default.existsSync(packageManagerTemplate)) {
|
353
|
-
import_fs.default.cpSync(packageManagerTemplate, projectDir, {
|
354
|
-
recursive: true,
|
355
|
-
force: true
|
356
|
-
});
|
357
|
-
}
|
358
|
-
import_fs.default.renameSync(
|
359
|
-
path2.join(projectDir, "gitignore"),
|
360
|
-
path2.join(projectDir, ".gitignore")
|
361
|
-
);
|
362
|
-
let sharedPkg = require(path2.join(sharedTemplate, "package.json"));
|
363
|
-
let projectPkg = require(path2.join(projectDir, "package.json"));
|
364
|
-
["dependencies", "devDependencies"].forEach((pkgKey) => {
|
365
|
-
sharedPkg[pkgKey] = {
|
366
|
-
...sharedPkg[pkgKey],
|
367
|
-
...projectPkg[pkgKey]
|
368
|
-
};
|
369
|
-
});
|
370
|
-
sharedPkg.packageManager = `${packageManager.command}@${packageManagerVersion}`;
|
371
|
-
sharedPkg.name = projectName;
|
372
|
-
import_fs.default.writeFileSync(
|
373
|
-
path2.join(projectDir, "package.json"),
|
374
|
-
JSON.stringify(sharedPkg, null, 2)
|
375
|
-
);
|
376
|
-
console.log();
|
377
|
-
console.log(`>>> Created a new turborepo with the following:`);
|
378
|
-
console.log();
|
379
|
-
console.log(` - ${import_chalk.default.bold("apps/web")}: Next.js with TypeScript`);
|
380
|
-
console.log(` - ${import_chalk.default.bold("apps/docs")}: Next.js with TypeScript`);
|
381
|
-
console.log(
|
382
|
-
` - ${import_chalk.default.bold("packages/ui")}: Shared React component library`
|
383
|
-
);
|
384
|
-
console.log(
|
385
|
-
` - ${import_chalk.default.bold(
|
386
|
-
"packages/eslint-config-custom"
|
387
|
-
)}: Shared configuration (ESLint)`
|
388
|
-
);
|
389
|
-
console.log(
|
390
|
-
` - ${import_chalk.default.bold("packages/tsconfig")}: Shared TypeScript \`tsconfig.json\``
|
391
|
-
);
|
392
|
-
console.log();
|
393
|
-
if (flags.install) {
|
394
|
-
const spinner = (0, import_ora.default)({
|
395
|
-
text: "Installing dependencies...",
|
396
|
-
spinner: {
|
397
|
-
frames: [" ", "> ", ">> ", ">>>"]
|
398
|
-
}
|
399
|
-
}).start();
|
400
|
-
await (0, import_execa.default)(`${packageManager.command}`, packageManager.installArgs, {
|
401
|
-
stdio: "ignore",
|
402
|
-
cwd: projectDir
|
403
|
-
});
|
404
|
-
spinner.stop();
|
405
|
-
}
|
406
|
-
process.chdir(projectDir);
|
407
|
-
tryGitInit(relativeProjectDir);
|
408
|
-
if (projectDirIsCurrentDir) {
|
409
|
-
console.log(
|
410
|
-
`${import_chalk.default.bold(
|
411
|
-
turboGradient(">>> Success!")
|
412
|
-
)} Your new Turborepo is ready.`
|
413
|
-
);
|
414
|
-
console.log("Inside this directory, you can run several commands:");
|
415
|
-
} else {
|
416
|
-
console.log(
|
417
|
-
`${import_chalk.default.bold(
|
418
|
-
turboGradient(">>> Success!")
|
419
|
-
)} Created a new Turborepo at "${relativeProjectDir}".`
|
420
|
-
);
|
421
|
-
console.log("Inside that directory, you can run several commands:");
|
422
|
-
}
|
423
|
-
console.log();
|
424
|
-
console.log(import_chalk.default.cyan(` ${packageManager.command} run build`));
|
425
|
-
console.log(` Build all apps and packages`);
|
426
|
-
console.log();
|
427
|
-
console.log(import_chalk.default.cyan(` ${packageManager.command} run dev`));
|
428
|
-
console.log(` Develop all apps and packages`);
|
429
|
-
console.log();
|
430
|
-
console.log(`Turborepo will cache locally by default. For an additional`);
|
431
|
-
console.log(`speed boost, enable Remote Caching with Vercel by`);
|
432
|
-
console.log(`entering the following command:`);
|
433
|
-
console.log();
|
434
|
-
console.log(import_chalk.default.cyan(` ${packageManager.executable} turbo login`));
|
435
|
-
console.log();
|
436
|
-
console.log(`We suggest that you begin by typing:`);
|
437
|
-
console.log();
|
438
|
-
if (!projectDirIsCurrentDir) {
|
439
|
-
console.log(` ${import_chalk.default.cyan("cd")} ${relativeProjectDir}`);
|
440
|
-
}
|
441
|
-
console.log(import_chalk.default.cyan(` ${packageManager.executable} turbo login`));
|
442
|
-
console.log();
|
443
|
-
}
|
444
|
-
var update = (0, import_update_check.default)(package_default).catch(() => null);
|
445
|
-
async function notifyUpdate() {
|
446
|
-
try {
|
447
|
-
const res = await update;
|
448
|
-
if (res == null ? void 0 : res.latest) {
|
449
|
-
const isYarn = shouldUseYarn();
|
450
|
-
console.log();
|
451
|
-
console.log(
|
452
|
-
import_chalk.default.yellow.bold("A new version of `create-turbo` is available!")
|
453
|
-
);
|
454
|
-
console.log(
|
455
|
-
"You can update by running: " + import_chalk.default.cyan(
|
456
|
-
isYarn ? "yarn global add create-turbo" : "npm i -g create-turbo"
|
457
|
-
)
|
458
|
-
);
|
459
|
-
console.log();
|
460
|
-
}
|
461
|
-
process.exit();
|
462
|
-
} catch {
|
463
|
-
}
|
464
|
-
}
|