create-turbo 1.6.3-canary.0 → 1.7.0-canary.0

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