create-tina-app 1.6.0 → 1.6.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.
Files changed (2) hide show
  1. package/dist/index.js +85 -96
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -7,10 +7,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
- var __export = (target, all) => {
11
- for (var name2 in all)
12
- __defProp(target, name2, { get: all[name2], enumerable: true });
13
- };
14
10
  var __copyProps = (to, from, except, desc) => {
15
11
  if (from && typeof from === "object" || typeof from === "function") {
16
12
  for (let key of __getOwnPropNames(from))
@@ -27,14 +23,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
23
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
24
  mod
29
25
  ));
30
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
26
 
32
27
  // package.json
33
28
  var require_package = __commonJS({
34
- "package.json"(exports2, module2) {
35
- module2.exports = {
29
+ "package.json"(exports, module) {
30
+ module.exports = {
36
31
  name: "create-tina-app",
37
- version: "1.6.0",
32
+ version: "1.6.2",
38
33
  main: "dist/index.js",
39
34
  files: [
40
35
  "dist",
@@ -82,7 +77,7 @@ var require_package = __commonJS({
82
77
  commander: "^12.1.0",
83
78
  "cross-spawn": "catalog:",
84
79
  "fs-extra": "catalog:",
85
- ora: "^8.2.0",
80
+ ora: "catalog:",
86
81
  prompts: "catalog:",
87
82
  tar: "catalog:",
88
83
  "validate-npm-package-name": "catalog:"
@@ -92,36 +87,31 @@ var require_package = __commonJS({
92
87
  });
93
88
 
94
89
  // src/index.ts
95
- var index_exports = {};
96
- __export(index_exports, {
97
- run: () => run
98
- });
99
- module.exports = __toCommonJS(index_exports);
100
- var import_metrics = require("@tinacms/metrics");
101
- var import_prompts = __toESM(require("prompts"));
102
- var import_node_path = __toESM(require("node:path"));
90
+ import { Telemetry } from "@tinacms/metrics";
91
+ import prompts from "prompts";
92
+ import path4 from "node:path";
103
93
 
104
94
  // src/util/fileUtil.ts
105
- var import_fs_extra = __toESM(require("fs-extra"));
106
- var import_path = __toESM(require("path"));
95
+ import fs from "fs-extra";
96
+ import path from "path";
107
97
 
108
98
  // src/util/textstyles.ts
109
- var import_chalk = __toESM(require("chalk"));
99
+ import chalk from "chalk";
110
100
  var TextStyles = {
111
- tinaOrange: import_chalk.default.hex("#EC4816"),
112
- link: (url) => `\x1B]8;;${url}\x07${import_chalk.default.cyan.underline(url)}\x1B]8;;\x07`,
113
- cmd: import_chalk.default.bgBlackBright.bold.white,
114
- info: import_chalk.default.blue,
115
- success: import_chalk.default.green,
116
- warn: import_chalk.default.yellow,
117
- err: import_chalk.default.red,
118
- bold: import_chalk.default.bold
101
+ tinaOrange: chalk.hex("#EC4816"),
102
+ link: (url) => `\x1B]8;;${url}\x07${chalk.cyan.underline(url)}\x1B]8;;\x07`,
103
+ cmd: chalk.bgBlackBright.bold.white,
104
+ info: chalk.blue,
105
+ success: chalk.green,
106
+ warn: chalk.yellow,
107
+ err: chalk.red,
108
+ bold: chalk.bold
119
109
  };
120
110
 
121
111
  // src/util/fileUtil.ts
122
112
  async function isWriteable(directory) {
123
113
  try {
124
- await import_fs_extra.default.promises.access(directory, (import_fs_extra.default.constants || import_fs_extra.default).W_OK);
114
+ await fs.promises.access(directory, (fs.constants || fs).W_OK);
125
115
  return true;
126
116
  } catch (err) {
127
117
  return false;
@@ -148,12 +138,12 @@ function folderContainsInstallConflicts(root) {
148
138
  "yarn-debug.log",
149
139
  "yarn-error.log"
150
140
  ];
151
- const conflicts = import_fs_extra.default.readdirSync(root).filter((file) => !validFiles.includes(file)).filter((file) => !/\.iml$/.test(file));
141
+ const conflicts = fs.readdirSync(root).filter((file) => !validFiles.includes(file)).filter((file) => !/\.iml$/.test(file));
152
142
  return conflicts;
153
143
  }
154
144
  async function setupProjectDirectory(dir) {
155
- const appName = import_path.default.basename(dir);
156
- await import_fs_extra.default.mkdirp(dir);
145
+ const appName = path.basename(dir);
146
+ await fs.mkdirp(dir);
157
147
  process.chdir(dir);
158
148
  const conflicts = folderContainsInstallConflicts(dir);
159
149
  if (conflicts.length > 0) {
@@ -162,7 +152,7 @@ async function setupProjectDirectory(dir) {
162
152
  ];
163
153
  for (const file of conflicts) {
164
154
  try {
165
- const stats = import_fs_extra.default.lstatSync(import_path.default.join(dir, file));
155
+ const stats = fs.lstatSync(path.join(dir, file));
166
156
  if (stats.isDirectory()) {
167
157
  errorMessageLines.push(` - ${TextStyles.info(file)}/`);
168
158
  } else {
@@ -177,36 +167,36 @@ async function setupProjectDirectory(dir) {
177
167
  return appName;
178
168
  }
179
169
  function updateProjectPackageName(dir, name2) {
180
- const packageJsonPath = import_path.default.join(dir, "package.json");
181
- const packageJson = JSON.parse(import_fs_extra.default.readFileSync(packageJsonPath, "utf8"));
170
+ const packageJsonPath = path.join(dir, "package.json");
171
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
182
172
  packageJson.name = name2;
183
- import_fs_extra.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
173
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
184
174
  }
185
175
  function updateProjectPackageVersion(dir, version2) {
186
- const packageJsonPath = import_path.default.join(dir, "package.json");
187
- const packageJson = JSON.parse(import_fs_extra.default.readFileSync(packageJsonPath, "utf8"));
176
+ const packageJsonPath = path.join(dir, "package.json");
177
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
188
178
  packageJson.version = version2;
189
- import_fs_extra.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
179
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
190
180
  }
191
181
  async function updateThemeSettings(dir, selectedTheme) {
192
- const settingsDir = import_path.default.join(dir, "content", "settings");
193
- const configPath = import_path.default.join(settingsDir, "config.json");
194
- await import_fs_extra.default.mkdirp(settingsDir);
182
+ const settingsDir = path.join(dir, "content", "settings");
183
+ const configPath = path.join(settingsDir, "config.json");
184
+ await fs.mkdirp(settingsDir);
195
185
  let config = {};
196
186
  try {
197
- const existingConfig = await import_fs_extra.default.readFile(configPath, "utf8");
187
+ const existingConfig = await fs.readFile(configPath, "utf8");
198
188
  config = JSON.parse(existingConfig);
199
189
  } catch (error) {
200
190
  }
201
191
  config.selectedTheme = selectedTheme;
202
- await import_fs_extra.default.writeFile(configPath, JSON.stringify(config, null, 2));
192
+ await fs.writeFile(configPath, JSON.stringify(config, null, 2));
203
193
  }
204
194
 
205
195
  // src/util/install.ts
206
- var import_cross_spawn = __toESM(require("cross-spawn"));
196
+ import spawn from "cross-spawn";
207
197
  function install(packageManager, verboseOutput) {
208
198
  return new Promise((resolve, reject) => {
209
- const child = (0, import_cross_spawn.default)(packageManager, ["install"], {
199
+ const child = spawn(packageManager, ["install"], {
210
200
  stdio: verboseOutput ? "inherit" : "ignore",
211
201
  env: { ...process.env, ADBLOCK: "1", DISABLE_OPENCOLLECTIVE: "1" }
212
202
  });
@@ -221,12 +211,12 @@ function install(packageManager, verboseOutput) {
221
211
  }
222
212
 
223
213
  // src/util/git.ts
224
- var import_child_process = require("child_process");
225
- var import_path2 = __toESM(require("path"));
226
- var import_fs_extra2 = __toESM(require("fs-extra"));
214
+ import { execSync } from "child_process";
215
+ import path2 from "path";
216
+ import fs2 from "fs-extra";
227
217
  function isInGitRepository() {
228
218
  try {
229
- (0, import_child_process.execSync)("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
219
+ execSync("git rev-parse --is-inside-work-tree", { stdio: "ignore" });
230
220
  return true;
231
221
  } catch (_) {
232
222
  }
@@ -234,7 +224,7 @@ function isInGitRepository() {
234
224
  }
235
225
  function isInMercurialRepository() {
236
226
  try {
237
- (0, import_child_process.execSync)("hg --cwd . root", { stdio: "ignore" });
227
+ execSync("hg --cwd . root", { stdio: "ignore" });
238
228
  return true;
239
229
  } catch (_) {
240
230
  }
@@ -242,27 +232,27 @@ function isInMercurialRepository() {
242
232
  }
243
233
  function makeFirstCommit(root) {
244
234
  try {
245
- (0, import_child_process.execSync)("git checkout -b main", { stdio: "ignore" });
246
- (0, import_child_process.execSync)("git add -A", { stdio: "ignore" });
247
- (0, import_child_process.execSync)('git commit -m "Initial commit from Create Tina App"', {
235
+ execSync("git checkout -b main", { stdio: "ignore" });
236
+ execSync("git add -A", { stdio: "ignore" });
237
+ execSync('git commit -m "Initial commit from Create Tina App"', {
248
238
  stdio: "ignore"
249
239
  });
250
240
  } catch (err) {
251
- import_fs_extra2.default.removeSync(import_path2.default.join(root, ".git"));
241
+ fs2.removeSync(path2.join(root, ".git"));
252
242
  throw err;
253
243
  }
254
244
  }
255
245
  function initializeGit(spinner) {
256
- (0, import_child_process.execSync)("git --version", { stdio: "ignore" });
246
+ execSync("git --version", { stdio: "ignore" });
257
247
  if (isInGitRepository() || isInMercurialRepository()) {
258
248
  spinner.warn("Already in a Git repository, skipping.");
259
249
  return false;
260
250
  }
261
- if (!import_fs_extra2.default.existsSync(".gitignore")) {
251
+ if (!fs2.existsSync(".gitignore")) {
262
252
  spinner.warn(
263
253
  "There is no .gitignore file in this repository, creating one..."
264
254
  );
265
- import_fs_extra2.default.writeFileSync(
255
+ fs2.writeFileSync(
266
256
  ".gitignore",
267
257
  `node_modules
268
258
  .yarn/*
@@ -272,14 +262,14 @@ function initializeGit(spinner) {
272
262
  `
273
263
  );
274
264
  }
275
- (0, import_child_process.execSync)("git init", { stdio: "ignore" });
265
+ execSync("git init", { stdio: "ignore" });
276
266
  return true;
277
267
  }
278
268
 
279
269
  // src/util/examples.ts
280
- var import_node_stream = require("node:stream");
281
- var import_promises = require("node:stream/promises");
282
- var import_tar = require("tar");
270
+ import { Readable } from "node:stream";
271
+ import { pipeline } from "node:stream/promises";
272
+ import { x } from "tar";
283
273
  async function getRepoInfo(url, examplePath) {
284
274
  const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
285
275
  const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
@@ -314,14 +304,14 @@ async function downloadTarStream(url) {
314
304
  if (!res.body) {
315
305
  throw new Error(`Failed to download: ${url}`);
316
306
  }
317
- return import_node_stream.Readable.fromWeb(res.body);
307
+ return Readable.fromWeb(res.body);
318
308
  }
319
309
  async function downloadAndExtractRepo(root, { username, name: name2, branch, filePath }) {
320
- await (0, import_promises.pipeline)(
310
+ await pipeline(
321
311
  await downloadTarStream(
322
312
  `https://codeload.github.com/${username}/${name2}/tar.gz/${branch}`
323
313
  ),
324
- (0, import_tar.x)({
314
+ x({
325
315
  cwd: root,
326
316
  strip: filePath ? filePath.split("/").length + 1 : 1,
327
317
  filter: (p) => p.startsWith(
@@ -332,8 +322,8 @@ async function downloadAndExtractRepo(root, { username, name: name2, branch, fil
332
322
  }
333
323
 
334
324
  // src/templates.ts
335
- var import_fs_extra3 = require("fs-extra");
336
- var import_path3 = __toESM(require("path"));
325
+ import { copy } from "fs-extra";
326
+ import path3 from "path";
337
327
  var TEMPLATES = [
338
328
  {
339
329
  title: "\u2B50 NextJS starter",
@@ -404,8 +394,8 @@ async function downloadTemplate(template, root, spinner) {
404
394
  )}`;
405
395
  await downloadAndExtractRepo(root, repoInfo);
406
396
  } else {
407
- const templateFile = import_path3.default.join(__dirname, "..", "examples", template.value);
408
- await (0, import_fs_extra3.copy)(`${templateFile}/`, "./");
397
+ const templateFile = path3.join(__dirname, "..", "examples", template.value);
398
+ await copy(`${templateFile}/`, "./");
409
399
  }
410
400
  }
411
401
 
@@ -429,11 +419,11 @@ function preRunChecks(spinner) {
429
419
  }
430
420
 
431
421
  // src/util/checkPkgManagers.ts
432
- var import_child_process2 = require("child_process");
422
+ import { exec } from "child_process";
433
423
  async function checkPackageExists(name2) {
434
424
  try {
435
425
  await new Promise((resolve, reject) => {
436
- (0, import_child_process2.exec)(`${name2} -v`, (error, stdout, stderr) => {
426
+ exec(`${name2} -v`, (error, stdout, stderr) => {
437
427
  if (error) {
438
428
  reject(stderr);
439
429
  }
@@ -447,11 +437,11 @@ async function checkPackageExists(name2) {
447
437
  }
448
438
 
449
439
  // src/index.ts
450
- var import_node_process = require("node:process");
440
+ import { exit } from "node:process";
451
441
 
452
442
  // src/util/options.ts
453
- var import_commander = require("commander");
454
443
  var import_package = __toESM(require_package());
444
+ import { Command } from "commander";
455
445
 
456
446
  // src/util/packageManagers.ts
457
447
  var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
@@ -459,7 +449,7 @@ var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
459
449
  // src/util/options.ts
460
450
  function extractOptions(args) {
461
451
  let projectName = "";
462
- const program = new import_commander.Command(import_package.name);
452
+ const program = new Command(import_package.name);
463
453
  program.version(import_package.version).option(
464
454
  "-t, --template <template>",
465
455
  `Choose which template to start from. Valid templates are: ${TEMPLATES.map(
@@ -486,7 +476,7 @@ function extractOptions(args) {
486
476
  }
487
477
 
488
478
  // src/index.ts
489
- var import_validate_npm_package_name = __toESM(require("validate-npm-package-name"));
479
+ import validate from "validate-npm-package-name";
490
480
 
491
481
  // src/util/asciiArt.ts
492
482
  var llama = " :--=: \n :-===- \n -=====- \n -=======. \n .=========-. \n :===========--:\n -=============.\n .==========-:. \n :=========-. \n -=========- \n .==========- \n -==========- \n :===========- \n -=============. \n :==============: \n :===============- \n .:-================- \n ..::---==================== \n ....::::::::::-------============================. \n .---=================================================: \n .-=====================================================- \n:=======================================================. \n .-====================================================. \n .-=================================================. \n :=============================================- \n -============================================. \n .============-:. -==========- \n :=========-: .. -==========. \n -========: :-=- -=========- \n .========. .-==== :=========: \n -=======: :=====. -========: \n -======- -====- -=======: \n -=====: -====: :======. \n .=====. -====. .-====- \n :==== -===- -====: \n -==- :===- :====. ";
@@ -541,7 +531,7 @@ async function run() {
541
531
  const spinner = ora();
542
532
  preRunChecks(spinner);
543
533
  const opts = extractOptions(process.argv);
544
- const telemetry = new import_metrics.Telemetry({ disabled: opts?.noTelemetry });
534
+ const telemetry = new Telemetry({ disabled: opts?.noTelemetry });
545
535
  let template = null;
546
536
  if (opts.template) {
547
537
  template = TEMPLATES.find((_template) => _template.value === opts.template);
@@ -551,7 +541,7 @@ async function run() {
551
541
  (x2) => x2.value
552
542
  )}`
553
543
  );
554
- (0, import_node_process.exit)(1);
544
+ exit(1);
555
545
  }
556
546
  }
557
547
  let pkgManager = opts.pkgManager;
@@ -560,7 +550,7 @@ async function run() {
560
550
  spinner.fail(
561
551
  `The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
562
552
  );
563
- (0, import_node_process.exit)(1);
553
+ exit(1);
564
554
  }
565
555
  }
566
556
  if (!pkgManager) {
@@ -574,9 +564,9 @@ async function run() {
574
564
  spinner.fail(
575
565
  `You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}`
576
566
  );
577
- (0, import_node_process.exit)(1);
567
+ exit(1);
578
568
  }
579
- const res = await (0, import_prompts.default)({
569
+ const res = await prompts({
580
570
  message: "Which package manager would you like to use?",
581
571
  name: "packageManager",
582
572
  type: "select",
@@ -584,46 +574,46 @@ async function run() {
584
574
  return { title: manager, value: manager };
585
575
  })
586
576
  });
587
- if (!Object.hasOwn(res, "packageManager")) (0, import_node_process.exit)(1);
577
+ if (!Object.hasOwn(res, "packageManager")) exit(1);
588
578
  pkgManager = res.packageManager;
589
579
  }
590
580
  let projectName = opts.projectName;
591
581
  if (!projectName) {
592
- const res = await (0, import_prompts.default)({
582
+ const res = await prompts({
593
583
  name: "name",
594
584
  type: "text",
595
585
  message: "What is your project named?",
596
586
  initial: "my-tina-app",
597
587
  validate: (name2) => {
598
- const { validForNewPackages, errors } = (0, import_validate_npm_package_name.default)(
599
- import_node_path.default.basename(import_node_path.default.resolve(name2))
588
+ const { validForNewPackages, errors } = validate(
589
+ path4.basename(path4.resolve(name2))
600
590
  );
601
591
  if (validForNewPackages) return true;
602
592
  return `Invalid project name: ${errors[0]}`;
603
593
  }
604
594
  });
605
- if (!Object.hasOwn(res, "name")) (0, import_node_process.exit)(1);
595
+ if (!Object.hasOwn(res, "name")) exit(1);
606
596
  projectName = res.name;
607
597
  }
608
598
  if (!template) {
609
- const res = await (0, import_prompts.default)({
599
+ const res = await prompts({
610
600
  name: "template",
611
601
  type: "select",
612
602
  message: "What starter code would you like to use?",
613
603
  choices: TEMPLATES
614
604
  });
615
- if (!Object.hasOwn(res, "template")) (0, import_node_process.exit)(1);
605
+ if (!Object.hasOwn(res, "template")) exit(1);
616
606
  template = TEMPLATES.find((_template) => _template.value === res.template);
617
607
  }
618
608
  let themeChoice;
619
609
  if (template.value === "tina-docs") {
620
- const res = await (0, import_prompts.default)({
610
+ const res = await prompts({
621
611
  name: "theme",
622
612
  type: "select",
623
613
  message: "What theme would you like to use?",
624
614
  choices: THEMES
625
615
  });
626
- if (!Object.hasOwn(res, "theme")) (0, import_node_process.exit)(1);
616
+ if (!Object.hasOwn(res, "theme")) exit(1);
627
617
  themeChoice = res.theme;
628
618
  }
629
619
  await telemetry.submitRecord({
@@ -633,8 +623,8 @@ async function run() {
633
623
  pkgManager
634
624
  }
635
625
  });
636
- const rootDir = import_node_path.default.join(process.cwd(), projectName);
637
- if (!await isWriteable(import_node_path.default.dirname(rootDir))) {
626
+ const rootDir = path4.join(process.cwd(), projectName);
627
+ if (!await isWriteable(path4.dirname(rootDir))) {
638
628
  spinner.fail(
639
629
  "The application path is not writable, please check folder permissions and try again. It is likely you do not have write permissions for this folder."
640
630
  );
@@ -645,7 +635,7 @@ async function run() {
645
635
  appName = await setupProjectDirectory(rootDir);
646
636
  } catch (err) {
647
637
  spinner.fail(err.message);
648
- (0, import_node_process.exit)(1);
638
+ exit(1);
649
639
  }
650
640
  try {
651
641
  await downloadTemplate(template, rootDir, spinner);
@@ -661,7 +651,7 @@ async function run() {
661
651
  spinner.succeed();
662
652
  } catch (err) {
663
653
  spinner.fail(`Failed to download template: ${err.message}`);
664
- (0, import_node_process.exit)(1);
654
+ exit(1);
665
655
  }
666
656
  spinner.start("Installing packages.");
667
657
  try {
@@ -714,7 +704,6 @@ run().catch((error) => {
714
704
  console.error("Error running create-tina-app:", error);
715
705
  process.exit(1);
716
706
  });
717
- // Annotate the CommonJS export names for ESM import in node:
718
- 0 && (module.exports = {
707
+ export {
719
708
  run
720
- });
709
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tina-app",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -35,7 +35,7 @@
35
35
  "@types/prompts": "^2.4.9",
36
36
  "@types/tar": "6.1.13",
37
37
  "typescript": "^5.7.3",
38
- "@tinacms/scripts": "1.4.0"
38
+ "@tinacms/scripts": "1.4.1"
39
39
  },
40
40
  "dependencies": {
41
41
  "chalk": "4.1.2",
@@ -46,7 +46,7 @@
46
46
  "prompts": "^2.4.2",
47
47
  "tar": "7.4.0",
48
48
  "validate-npm-package-name": "^5.0.1",
49
- "@tinacms/metrics": "1.1.0"
49
+ "@tinacms/metrics": "2.0.0"
50
50
  },
51
51
  "scripts": {
52
52
  "types": "pnpm tsc",